<html>
<head><meta charset="utf-8"><title>The libm problem · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html">The libm problem</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226608971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226608971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226608971">(Feb 17 2021 at 03:22)</a>:</h4>
<p>oh no</p>
<div class="codehilite" data-code-language="GAS"><pre><span></span><code>        <span class="nf">movq</span>    <span class="no">fmaf@GOTPCREL</span><span class="p">(</span><span class="nv">%rip</span><span class="p">),</span> <span class="nv">%rbx</span>
        <span class="nf">callq</span>   <span class="p">*</span><span class="nv">%rbx</span>
</code></pre></div>
<p>even <code>simd_fma</code> calls to libm</p>



<a name="226608988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226608988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226608988">(Feb 17 2021 at 03:23)</a>:</h4>
<p>Thats... Odd</p>



<a name="226608997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226608997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226608997">(Feb 17 2021 at 03:23)</a>:</h4>
<p>Maybe it's because of the rounding issue?</p>



<a name="226609069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609069">(Feb 17 2021 at 03:25)</a>:</h4>
<p><a href="https://rust.godbolt.org/z/hxxadY">https://rust.godbolt.org/z/hxxadY</a></p>



<a name="226609092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609092">(Feb 17 2021 at 03:25)</a>:</h4>
<div class="codehilite" data-code-language="GAS"><pre><span></span><code>        <span class="nf">movq</span>    <span class="no">ceilf@GOTPCREL</span><span class="p">(</span><span class="nv">%rip</span><span class="p">),</span> <span class="nv">%rbx</span>
        <span class="nf">callq</span>   <span class="p">*</span><span class="nv">%rbx</span>
</code></pre></div>
<p>oh nooooooo</p>



<a name="226609280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609280">(Feb 17 2021 at 03:30)</a>:</h4>
<p>hmm</p>



<a name="226609326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609326">(Feb 17 2021 at 03:30)</a>:</h4>
<p>how are they handled for <code>f32</code>?</p>



<a name="226609368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609368">(Feb 17 2021 at 03:31)</a>:</h4>
<p><a href="https://doc.rust-lang.org/core/intrinsics/fn.ceilf32.html">https://doc.rust-lang.org/core/intrinsics/fn.ceilf32.html</a></p>



<a name="226609372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609372">(Feb 17 2021 at 03:31)</a>:</h4>
<p>whatever this lowers to</p>



<a name="226609477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609477">(Feb 17 2021 at 03:33)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/bb587b1a1737738658d2eaecd4c8c1cab555257a/compiler/rustc_codegen_llvm/src/intrinsic.rs#L61">https://github.com/rust-lang/rust/blob/bb587b1a1737738658d2eaecd4c8c1cab555257a/compiler/rustc_codegen_llvm/src/intrinsic.rs#L61</a></p>



<a name="226609480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609480">(Feb 17 2021 at 03:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226608971">said</a>:</p>
<blockquote>
<p>oh no</p>
<div class="codehilite" data-code-language="GAS"><pre><span></span><code>        <span class="nf">movq</span>    <span class="no">fmaf@GOTPCREL</span><span class="p">(</span><span class="nv">%rip</span><span class="p">),</span> <span class="nv">%rbx</span>
        <span class="nf">callq</span>   <span class="p">*</span><span class="nv">%rbx</span>
</code></pre></div>
<p>even <code>simd_fma</code> calls to libm</p>
</blockquote>
<p>that's because you forgot to enable the fma instruction set:<br>
<a href="https://rust.godbolt.org/z/r4j5Gv">https://rust.godbolt.org/z/r4j5Gv</a></p>



<a name="226609484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609484">(Feb 17 2021 at 03:33)</a>:</h4>
<p>it just lowers to llvm's <code>ceil</code> instruction</p>



<a name="226609531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609531">(Feb 17 2021 at 03:34)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> the problem isn't that it called libm instead of an instruction, specifically, the problem is that it called libm which isn't available in core</p>



<a name="226609547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609547">(Feb 17 2021 at 03:34)</a>:</h4>
<p>rather than llvm generating an inline codelet</p>



<a name="226609566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609566">(Feb 17 2021 at 03:35)</a>:</h4>
<p>i'm curious why this is ok for <code>f32::ceil</code></p>



<a name="226609571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609571">(Feb 17 2021 at 03:35)</a>:</h4>
<p>well, you'll just have to leave fma out of core then -- fma requires library support on x86 without the fma instruction set</p>



<a name="226609579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609579">(Feb 17 2021 at 03:35)</a>:</h4>
<p>My understanding is that floats are in fact split this way.</p>



<a name="226609582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609582">(Feb 17 2021 at 03:36)</a>:</h4>
<p>inside the compiler.</p>



<a name="226609637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609637">(Feb 17 2021 at 03:36)</a>:</h4>
<p>oh there's an intrinsics crate, isn't there</p>



<a name="226609643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609643">(Feb 17 2021 at 03:37)</a>:</h4>
<p>it's llvm that's generating the fma function calls, rustc is passing the vector instructions like it should</p>



<a name="226609644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609644">(Feb 17 2021 at 03:37)</a>:</h4>
<p>compiler builtins or something</p>



<a name="226609653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609653">(Feb 17 2021 at 03:37)</a>:</h4>
<p>and yeah, the problem is that it's like</p>



<a name="226609661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609661">(Feb 17 2021 at 03:37)</a>:</h4>
<p>it complicates our life since now we have to split stuff between core and std lol</p>



<a name="226609662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609662">(Feb 17 2021 at 03:37)</a>:</h4>
<p>we should be able to do <code>SimdF32::ceil</code> identically to <code>f32::ceil</code></p>



<a name="226609736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609736">(Feb 17 2021 at 03:39)</a>:</h4>
<p>it seems pretty bad for these vector operations to lower to 4 function calls</p>



<a name="226609794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609794">(Feb 17 2021 at 03:40)</a>:</h4>
<p>I think the idea behind the trig stuff also was that we'd provide a decent software vectorized impl. that should be possible for most of these too</p>



<a name="226609839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609839">(Feb 17 2021 at 03:41)</a>:</h4>
<p>the logic of calling into libm since it can do better than we can doesn't necessarily apply if we can do it vectorized rather than multiple scalar ops</p>



<a name="226609850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609850">(Feb 17 2021 at 03:41)</a>:</h4>
<p>well, if you wanted it to generate a mul+add or fma whichever's faster, there's a separate llvm operation for that. if you ask for fma and only fma, it has to use the only fma function available -- libm's</p>



<a name="226609858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609858">(Feb 17 2021 at 03:41)</a>:</h4>
<p>also it shouldn't matter actually that I'm not flagging for vector features.<br>
godbolt is on an x64 machine, isn't it?</p>



<a name="226609910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609910">(Feb 17 2021 at 03:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226609850">said</a>:</p>
<blockquote>
<p>well, if you wanted it to generate a mul+add or fma whichever's faster</p>
</blockquote>
<p>i definitely didn't say that</p>



<a name="226609991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226609991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226609991">(Feb 17 2021 at 03:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226609858">said</a>:</p>
<blockquote>
<p>godbolt is on an x64 machine, isn't it?</p>
</blockquote>
<p>yup, though you can easily use <code>--target=...</code> to change it</p>



<a name="226610211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226610211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226610211">(Feb 17 2021 at 03:48)</a>:</h4>
<p>IMHO when rustc is asked to target x86_64-unknown-linux-gnu, it should be able to assume that libm is available, even when using no_std, after all, that's what the gnu part means -- use glibc</p>



<a name="226610438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226610438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226610438">(Feb 17 2021 at 03:52)</a>:</h4>
<p>unfortunately, there aren't any x86_64 rustc targets without a libm that I'm aware of, otherwise we could test and ensure that fma isn't called in those situations, it might have to abort compilation, but it shouldn't use a function llvm was told isn't available</p>



<a name="226610488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226610488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226610488">(Feb 17 2021 at 03:53)</a>:</h4>
<p>-elf</p>



<a name="226610556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226610556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226610556">(Feb 17 2021 at 03:54)</a>:</h4>
<p>well, at least fabs and fsqrt compile to vector instructions always... on x64</p>



<a name="226611040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611040">(Feb 17 2021 at 04:03)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> the reason I question that is because this exists: <a href="https://doc.rust-lang.org/core/intrinsics/fn.fmaf32.html">https://doc.rust-lang.org/core/intrinsics/fn.fmaf32.html</a></p>



<a name="226611124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611124">(Feb 17 2021 at 04:04)</a>:</h4>
<p>unless this doesn't actually allow fma in core, just the intrinsic</p>



<a name="226611240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611240">(Feb 17 2021 at 04:06)</a>:</h4>
<p>oh that's it</p>



<a name="226611247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611247">(Feb 17 2021 at 04:06)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error[E0599]: no method named `mul_add` found for type `{float}` in the current scope
 --&gt; src/main.rs:4:17
  |
4 |     let _ = 2.0.mul_add(3.0, 4.0);
  |                 ^^^^^^^ method not found in `{float}`
</code></pre></div>



<a name="226611298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611298">(Feb 17 2021 at 04:07)</a>:</h4>
<p>I think we should follow the same path and only provide them in <code>std</code>, then</p>



<a name="226611352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611352">(Feb 17 2021 at 04:08)</a>:</h4>
<p>getting things working in core that don't even work for <code>f32</code> core is probably out of the scope of this...</p>



<a name="226611381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611381">(Feb 17 2021 at 04:09)</a>:</h4>
<p>Yeah, I just wanted to raise this as a much more concrete problem.</p>



<a name="226611708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611708">(Feb 17 2021 at 04:14)</a>:</h4>
<p>since, uh,<br>
puts a SLIGHT CRAMP<br>
into launching into nightly</p>



<a name="226611723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611723">(Feb 17 2021 at 04:14)</a>:</h4>
<p>Yeah a bit lol.</p>



<a name="226611756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611756">(Feb 17 2021 at 04:15)</a>:</h4>
<p>Though it should be pretty easy to identify which functions result in libm calls</p>



<a name="226611824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226611824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226611824">(Feb 17 2021 at 04:16)</a>:</h4>
<p>I wonder if we just add a <code>std</code> (or <code>libm</code> to be more specific?) cargo feature and leave that to integration</p>



<a name="226613261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613261">(Feb 17 2021 at 04:41)</a>:</h4>
<p>Github issue: <a href="https://github.com/rust-lang/stdsimd/issues/76">https://github.com/rust-lang/stdsimd/issues/76</a></p>



<a name="226613423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613423">(Feb 17 2021 at 04:45)</a>:</h4>
<p>basically we (the rust project) need to fix the "floats in core" issue eventually, but we (the simd-wg) could skip on it for now, but if we do that we also lose all of our cool points forever.</p>



<a name="226613534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613534">(Feb 17 2021 at 04:47)</a>:</h4>
<p>I kinda agree, at least somewhat.<br>
Can you start sketching out how addressing that looks like? You don't have to make all the PRs, but you seem to have a better idea of what all the problems are, and we need action-items we can action on instead of <em>sweeping gesture</em></p>



<a name="226613622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613622">(Feb 17 2021 at 04:49)</a>:</h4>
<p>I think there's nothing we can do about it (right now).  Like rounding has specific instructions on some architectures and if we make our own implementation it will just be dramatically worse than those</p>



<a name="226613728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613728">(Feb 17 2021 at 04:51)</a>:</h4>
<p>So I guess my concern isn't so much that we need libm (we don't) but that we have no way of conditioning on target features</p>



<a name="226613829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613829">(Feb 17 2021 at 04:52)</a>:</h4>
<p>Like the trig functions are a good example, we should definitely make our own branchless implementations of all of those functions, but how do we get sin and cos in the first place?</p>



<a name="226613920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613920">(Feb 17 2021 at 04:54)</a>:</h4>
<p>Though perhaps there is an argument that if the function is small enough, losing the function call makes up for potentially not being as good as libm</p>



<a name="226613951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613951">(Feb 17 2021 at 04:55)</a>:</h4>
<p>sin and cos (just to pick some examples) can be performed in simd, and in fact you don't need advanced target features</p>



<a name="226613972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226613972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226613972">(Feb 17 2021 at 04:55)</a>:</h4>
<p>using advanced target features would be problematic, that's for sure, because core is pre-compiled</p>



<a name="226614045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614045">(Feb 17 2021 at 04:56)</a>:</h4>
<p>It's also worth noting that all of these are tedious, one-by-one, scalar calls.</p>



<a name="226614052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614052">(Feb 17 2021 at 04:57)</a>:</h4>
<p>Sorry that's not a good example</p>



<a name="226614056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614056">(Feb 17 2021 at 04:57)</a>:</h4>
<p>Here's a more concrete example</p>



<a name="226614136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614136">(Feb 17 2021 at 04:58)</a>:</h4>
<p>SSE 4.1 introduces the <code>roundps</code> instruction, and AVX adds <code>vroundps</code></p>



<a name="226614174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614174">(Feb 17 2021 at 04:59)</a>:</h4>
<p>Since we are not the backend, there is no way for us to conditionally use those instructions for rounding when those features are available</p>



<a name="226614261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614261">(Feb 17 2021 at 05:01)</a>:</h4>
<p>you can use conditional compilation still. though, honestly i don't know how that interacts with inline attribute, if you only inline the already conditional computed code or what.</p>



<a name="226614265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614265">(Feb 17 2021 at 05:01)</a>:</h4>
<p>Any rounding implementation we can write will be significantly worse than that</p>



<a name="226614283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614283">(Feb 17 2021 at 05:01)</a>:</h4>
<p>Conditional compilation doesn't work for two reasons, one because core is compiled with no features, and two because it won't work with runtime dispatch</p>



<a name="226614295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614295">(Feb 17 2021 at 05:02)</a>:</h4>
<p>i don't know why runtime dispatch matters</p>



<a name="226614349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614349">(Feb 17 2021 at 05:02)</a>:</h4>
<p>Personally the only SIMD I have ever used professionally has been runtime dispatched</p>



<a name="226614359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614359">(Feb 17 2021 at 05:03)</a>:</h4>
<p>I've always seen it compile time dispatched ;P</p>



<a name="226614385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614385">(Feb 17 2021 at 05:03)</a>:</h4>
<p>though i only programmed professionally for a short time once 15 years ago</p>



<a name="226614398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614398">(Feb 17 2021 at 05:03)</a>:</h4>
<p>I've never downloaded a binary and it asked me if I had AVX lol</p>



<a name="226614455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614455">(Feb 17 2021 at 05:04)</a>:</h4>
<p>right, you'd just not get avx support</p>



<a name="226614462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614462">(Feb 17 2021 at 05:04)</a>:</h4>
<p>or the program would use multi-versioning</p>



<a name="226614471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614471">(Feb 17 2021 at 05:04)</a>:</h4>
<p>Yeah when I say runtime dispatch I mean multiversioning</p>



<a name="226614474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614474">(Feb 17 2021 at 05:04)</a>:</h4>
<p>but you wouldn't runtime dispatch <em>within</em> the call to the round function</p>



<a name="226614476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614476">(Feb 17 2021 at 05:04)</a>:</h4>
<p>Though it could be broader than multiversioning as well</p>



<a name="226614487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614487">(Feb 17 2021 at 05:05)</a>:</h4>
<p>Intel does their dispatch with the dynamic linker once at load time</p>



<a name="226614513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614513">(Feb 17 2021 at 05:05)</a>:</h4>
<p>I agree it wouldn't just be for the round function</p>



<a name="226614578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614578">(Feb 17 2021 at 05:06)</a>:</h4>
<p>Which is my point, it's not possible for us to write a round function that detects the target features it's being inlined into</p>



<a name="226614613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614613">(Feb 17 2021 at 05:07)</a>:</h4>
<p>Any implementation we write will be strictly bad on anything SSE4.1 or later (so almost everything)</p>



<a name="226614688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614688">(Feb 17 2021 at 05:08)</a>:</h4>
<p>well then we better give up on simd <em>at all</em> because llvm is gonna emit those four libm calls unless sse4.1 is on at compile time</p>



<a name="226614703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614703">(Feb 17 2021 at 05:09)</a>:</h4>
<p>so you won't be able to make a runtime dispatch</p>



<a name="226614714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614714">(Feb 17 2021 at 05:09)</a>:</h4>
<p>No, it will emit roundps if you inline into a function that has the SSE4.1 target feature</p>



<a name="226614721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614721">(Feb 17 2021 at 05:09)</a>:</h4>
<p>This is still worth it even if it is only integers.</p>



<a name="226614722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614722">(Feb 17 2021 at 05:09)</a>:</h4>
<p>I say, trying to convince myself.</p>



<a name="226614785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614785">(Feb 17 2021 at 05:10)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> well then why can't we use conditional compilation and rely on it being inlined appropriately</p>



<a name="226614794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614794">(Feb 17 2021 at 05:11)</a>:</h4>
<p>Because conditional compilation happens before codegen</p>



<a name="226614809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614809">(Feb 17 2021 at 05:11)</a>:</h4>
<p>It's basically textual</p>



<a name="226614822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614822">(Feb 17 2021 at 05:11)</a>:</h4>
<p>I believe it happens before even lowering to HIR</p>



<a name="226614866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614866">(Feb 17 2021 at 05:12)</a>:</h4>
<p>then we're pretty effed</p>



<a name="226614874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614874">(Feb 17 2021 at 05:12)</a>:</h4>
<p>like you'd have to use build-std</p>



<a name="226614876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614876">(Feb 17 2021 at 05:12)</a>:</h4>
<p>No I think we just need to solve it the "right" way which is make a libm that can be linked statically into core</p>



<a name="226614899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614899">(Feb 17 2021 at 05:13)</a>:</h4>
<p>That's "we" as in rust generally</p>



<a name="226614904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614904">(Feb 17 2021 at 05:13)</a>:</h4>
<p>even if libm were in core, four calls to a scalar op is bad</p>



<a name="226614919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614919">(Feb 17 2021 at 05:13)</a>:</h4>
<p>Agreed but I don't think there's anything we can do short of making llvm better</p>



<a name="226614922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614922">(Feb 17 2021 at 05:13)</a>:</h4>
<p>Or alternatively</p>



<a name="226614927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614927">(Feb 17 2021 at 05:14)</a>:</h4>
<p>if you set the right -Ctarget-feature then stuff gets inlined.</p>



<a name="226614983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614983">(Feb 17 2021 at 05:14)</a>:</h4>
<p>but core is compiled before that</p>



<a name="226614988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614988">(Feb 17 2021 at 05:14)</a>:</h4>
<p>mm.</p>



<a name="226614989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614989">(Feb 17 2021 at 05:14)</a>:</h4>
<p>core is shipped with rustup by default</p>



<a name="226614995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614995">(Feb 17 2021 at 05:14)</a>:</h4>
<p>Since these functions are inlined they are just mir basically, afaik</p>



<a name="226614999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226614999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226614999">(Feb 17 2021 at 05:14)</a>:</h4>
<p>I need a drink.</p>



<a name="226615008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615008">(Feb 17 2021 at 05:15)</a>:</h4>
<p>If they were not inlined then yes they'd all be SSE only</p>



<a name="226615014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615014">(Feb 17 2021 at 05:15)</a>:</h4>
<p>I do not have any whiskey in this house. Why do I have no whiskey in this house.</p>



<a name="226615019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615019">(Feb 17 2021 at 05:15)</a>:</h4>
<p>because it's tequila time</p>



<a name="226615021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615021">(Feb 17 2021 at 05:15)</a>:</h4>
<p>ha</p>



<a name="226615036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615036">(Feb 17 2021 at 05:15)</a>:</h4>
<p>tequila on tuesday, that's a thing</p>



<a name="226615081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615081">(Feb 17 2021 at 05:16)</a>:</h4>
<p>So the other way to solve this, which is also outside of our scope, is to improve #[target_feature] to allow detection of features based on the function you're inlining into (which may or may not even be possible)</p>



<a name="226615091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615091">(Feb 17 2021 at 05:16)</a>:</h4>
<p>fair enough</p>



<a name="226615093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615093">(Feb 17 2021 at 05:16)</a>:</h4>
<p>The other, <em>other</em> way of solving this would be to fix LLVM to produce better fallback vector code</p>



<a name="226615104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615104">(Feb 17 2021 at 05:16)</a>:</h4>
<p>that would certainly help the most people</p>



<a name="226615110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615110">(Feb 17 2021 at 05:17)</a>:</h4>
<p>but also would involve you writing c++</p>



<a name="226615125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615125">(Feb 17 2021 at 05:17)</a>:</h4>
<p>I do that everyday <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="226615146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615146">(Feb 17 2021 at 05:18)</a>:</h4>
<p>opinion: It's time to oxidize the dragon <span aria-label="smiling imp" class="emoji emoji-1f608" role="img" title="smiling imp">:smiling_imp:</span></p>



<a name="226615195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615195">(Feb 17 2021 at 05:18)</a>:</h4>
<p>just a small PR</p>



<a name="226615203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615203">(Feb 17 2021 at 05:19)</a>:</h4>
<p>I do wonder if it's possible in LLVM to detect the target features of the function you're inlined into</p>



<a name="226615212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615212">(Feb 17 2021 at 05:19)</a>:</h4>
<p>that's a feature that would desperately help multiversioning in general</p>



<a name="226615222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615222">(Feb 17 2021 at 05:19)</a>:</h4>
<p>anyways</p>



<a name="226615375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615375">(Feb 17 2021 at 05:22)</a>:</h4>
<p>I think it makes sense to just do what <code>f32</code> and <code>f64</code> do for now</p>



<a name="226615382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615382">(Feb 17 2021 at 05:22)</a>:</h4>
<p>since I think it will work "correctly" in the most cases</p>



<a name="226615617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615617">(Feb 17 2021 at 05:28)</a>:</h4>
<p>So looking into LLVM it is possible to query target features of a function so it should be possible to make them inherit (which would let us multiversion functions to avoid libm)</p>



<a name="226615646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226615646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226615646">(Feb 17 2021 at 05:28)</a>:</h4>
<p>maybe we need an RFC for stdsimd 2.0</p>



<a name="226616543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226616543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226616543">(Feb 17 2021 at 05:48)</a>:</h4>
<p>occasionally you go 2 steps forward and 10 steps back</p>



<a name="226617696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226617696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226617696">(Feb 17 2021 at 06:12)</a>:</h4>
<p>Also note: <em>even if</em> we fix it all, then things where the simd form depends on having a particular feature level should still get fallback code from us, because we can round a lot better than 4 libm calls even with just sse2</p>



<a name="226617783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226617783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226617783">(Feb 17 2021 at 06:14)</a>:</h4>
<p>You mean if we fix the problems that prevent us from providing the fallback code?</p>



<a name="226617811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226617811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226617811">(Feb 17 2021 at 06:15)</a>:</h4>
<p>we are going to get to nightly before we RFC stdsimd 2.0 lol</p>



<a name="226617823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226617823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226617823">(Feb 17 2021 at 06:15)</a>:</h4>
<p>Yeah that's kinda my point, I don't think there is any path to us providing the fallbacks</p>



<a name="226617877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226617877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226617877">(Feb 17 2021 at 06:16)</a>:</h4>
<p>Not in this project group I mean</p>



<a name="226617896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226617896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226617896">(Feb 17 2021 at 06:16)</a>:</h4>
<p>ehhh I think we kinda can, Lokathor seems to have an idea. It might be as "simple" as making a few PRs here and there.</p>



<a name="226617927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226617927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226617927">(Feb 17 2021 at 06:17)</a>:</h4>
<p>or I should say:<br>
I don't think we can fix this the most satisfactory way.</p>



<a name="226617944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226617944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226617944">(Feb 17 2021 at 06:17)</a>:</h4>
<p>But I think we can actually make a certain amount of... let's call it <em>investigatory</em> progress.</p>



<a name="226618009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226618009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226618009">(Feb 17 2021 at 06:18)</a>:</h4>
<p>I don't really see any way of doing it without a full multiversioning implementation of #[target_feature]</p>



<a name="226618039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226618039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226618039">(Feb 17 2021 at 06:19)</a>:</h4>
<p>Otherwise we're optimizing for the low performance case, not high performance</p>



<a name="226618230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226618230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226618230">(Feb 17 2021 at 06:23)</a>:</h4>
<p>I agree that dispatching to libm per element is probably something like 4x worse than a vector implementation for SSE, but the vector implementation is probably going to be orders of magnitude worse than the roundps instruction which only requires SSE4.1</p>



<a name="226618301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226618301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226618301">(Feb 17 2021 at 06:24)</a>:</h4>
<p>Just masking out the sign bit is already the same order of magnitude!</p>



<a name="226620979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226620979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226620979">(Feb 17 2021 at 07:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226618039">said</a>:</p>
<blockquote>
<p>Otherwise we're optimizing for the low performance case, not high performance</p>
</blockquote>
<p>Obligatory: Even if it is the low performance case, it's worth optimizing for code compiled under the default flags, since almost all code is compiled under the default flags.</p>



<a name="226621022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621022">(Feb 17 2021 at 07:17)</a>:</h4>
<p>example: you can ceil / floor with just sse2</p>



<a name="226621090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621090">(Feb 17 2021 at 07:18)</a>:</h4>
<p>it's multi-step rather than one instruction, but even that will be way <em>way</em> more efficient than going out of simd, making four calls to libm, and going back in to simd</p>



<a name="226621138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621138">(Feb 17 2021 at 07:19)</a>:</h4>
<p>Is almost all SIMD code compiled under the default flags?</p>



<a name="226621200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621200">(Feb 17 2021 at 07:20)</a>:</h4>
<p>unless the entire compilation process is fixed, it seems we are incapable of shipping people a core lib with more than default flags enabled, so we should make the most of default flags</p>



<a name="226621220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621220">(Feb 17 2021 at 07:20)</a>:</h4>
<p>Since the functions are inline it doesn't matter</p>



<a name="226621226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621226">(Feb 17 2021 at 07:20)</a>:</h4>
<p>we should probably address this to T-compiler.</p>



<a name="226621241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621241">(Feb 17 2021 at 07:21)</a>:</h4>
<p>but I agree that honestly, I am OK with pessimizing perf somewhat on our first go-around.</p>



<a name="226621250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621250">(Feb 17 2021 at 07:21)</a>:</h4>
<p>it matters because inline doesn't fix the problem here</p>



<a name="226621254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621254">(Feb 17 2021 at 07:21)</a>:</h4>
<p>LLVM's round instruction ends up in the user codegen, not the core lib codegen</p>



<a name="226621255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621255">(Feb 17 2021 at 07:21)</a>:</h4>
<p>our goal is to beat scalar, not beat a hypothetical best</p>



<a name="226621257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621257">(Feb 17 2021 at 07:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226621138">said</a>:</p>
<blockquote>
<p>Is almost all SIMD code compiled under the default flags?</p>
</blockquote>
<p>Yes, almost certainly.</p>



<a name="226621311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621311">(Feb 17 2021 at 07:22)</a>:</h4>
<p>That would imply no one writes AVX, which I think is definitely wrong</p>



<a name="226621321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621321">(Feb 17 2021 at 07:22)</a>:</h4>
<p>do you bother setting RUSTFLAGS="-Ctarget-cpu=native" and such when you do <code>cargo install</code>? or <code>cargo build --release</code>? Most people don't</p>



<a name="226621325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621325">(Feb 17 2021 at 07:22)</a>:</h4>
<p>if we need to tell people to -Zbuild-std to get best perf, then we'll do that.</p>



<a name="226621330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621330">(Feb 17 2021 at 07:22)</a>:</h4>
<p>imo</p>



<a name="226621350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621350">(Feb 17 2021 at 07:22)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> but <em>we can't call the llvm round instruction</em> if we don't know that sse4.1 is there. If we do, that's 4 libm calls. So if we don't know it'll be sse4.1 for sure, we have to take the sse2 path and <em>not call the llvm round instruction at all</em> and just do it ourselves</p>



<a name="226621372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621372">(Feb 17 2021 at 07:23)</a>:</h4>
<p>it sounds stupid, but is true</p>



<a name="226621375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621375">(Feb 17 2021 at 07:23)</a>:</h4>
<p>We can call the LLVM round instruction, just only in std</p>



<a name="226621430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621430">(Feb 17 2021 at 07:24)</a>:</h4>
<p>no, in std without sse4.1 that's what turns into the libm calls</p>



<a name="226621439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621439">(Feb 17 2021 at 07:24)</a>:</h4>
<p>It doesn't make sense to me to optimize a potentially 4x speedup (2x for f64) at the cost of maybe 100x slowdown for AVX</p>



<a name="226621442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621442">(Feb 17 2021 at 07:24)</a>:</h4>
<p>let's bench it.</p>



<a name="226621470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621470">(Feb 17 2021 at 07:25)</a>:</h4>
<p>avx would be able to avoid a slow down by telling people to use build-std</p>



<a name="226621587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621587">(Feb 17 2021 at 07:26)</a>:</h4>
<p>I think that's an unacceptable solution honestly, you shouldn't have to build std yourself to use AVX in a SIMD module of std</p>



<a name="226621596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621596">(Feb 17 2021 at 07:27)</a>:</h4>
<p>But I will note this is basically a compiler issue.<br>
It's not an API issue.<br>
We should not try to bend our API around the compiler being bad at compilation in any meaningful sense.<br>
We use the tools that are available, but otherwise, we should, rather, slam our faces directly into the bad compilation.</p>



<a name="226621630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621630">(Feb 17 2021 at 07:27)</a>:</h4>
<p>I agree that it's really not our problem since it already exists for f32 and f64</p>



<a name="226621681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621681">(Feb 17 2021 at 07:28)</a>:</h4>
<p><strong>however</strong>, our goal is still to compile to SIMD instructions.</p>



<a name="226621700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621700">(Feb 17 2021 at 07:28)</a>:</h4>
<p>And on x86_64 we can always do so.<br>
Optimizing beyond that is a compiler-level concern.</p>



<a name="226621742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621742">(Feb 17 2021 at 07:29)</a>:</h4>
<p>this is basically why we started talking to T-compiler about an MCP</p>



<a name="226621746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621746">(Feb 17 2021 at 07:29)</a>:</h4>
<p>:V</p>



<a name="226621749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621749">(Feb 17 2021 at 07:29)</a>:</h4>
<p>part of it anyways</p>



<a name="226621760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621760">(Feb 17 2021 at 07:29)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> your very own example shows that we don't get simd instructions</p>



<a name="226621764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621764">(Feb 17 2021 at 07:29)</a>:</h4>
<p>exactly.</p>



<a name="226621819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621819">(Feb 17 2021 at 07:30)</a>:</h4>
<p>so what did you mean by "we can always do so" then? ?_?</p>



<a name="226621820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621820">(Feb 17 2021 at 07:30)</a>:</h4>
<p>is there any idea how we'd fix it in the compiler though? Without a plan to do that, I uh, think it won't get fixed there. it's also a problem that is worse for SIMD than it is for non-SIMD code</p>



<a name="226621843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621843">(Feb 17 2021 at 07:30)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span>  I am basically saying that from my perspective it is better to default to SSE2 even if that pessimizes some other things a bit.</p>



<a name="226621857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621857">(Feb 17 2021 at 07:31)</a>:</h4>
<p>ah, yes i see</p>



<a name="226621882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621882">(Feb 17 2021 at 07:31)</a>:</h4>
<p>we should piss off our users until T-compiler fixes it, obviously. :^)</p>



<a name="226621920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621920">(Feb 17 2021 at 07:32)</a>:</h4>
<p>JOKING</p>



<a name="226621921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621921">(Feb 17 2021 at 07:32)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> the problem is that people dont have avx flags on by default so most people will get the ultra-slow libm path anyway.</p>



<a name="226621925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621925">(Feb 17 2021 at 07:32)</a>:</h4>
<p>I don't think it makes sense to prioritize SSE2 at all</p>



<a name="226621938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621938">(Feb 17 2021 at 07:32)</a>:</h4>
<p>as long as it's the default simd level we have to focus on the common case</p>



<a name="226621985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621985">(Feb 17 2021 at 07:33)</a>:</h4>
<p>But #[target_feature] is available and has been for a long time</p>



<a name="226621987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226621987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226621987">(Feb 17 2021 at 07:33)</a>:</h4>
<p>and anyone who knows enough to see that they want to set alternative rustflags will be able to also add a -Zbuild-std</p>



<a name="226622012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622012">(Feb 17 2021 at 07:34)</a>:</h4>
<p>Right but the problem is that bleeds into libraries then</p>



<a name="226622056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622056">(Feb 17 2021 at 07:34)</a>:</h4>
<p>...so?</p>



<a name="226622063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622063">(Feb 17 2021 at 07:34)</a>:</h4>
<p>bleads how?</p>



<a name="226622073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622073">(Feb 17 2021 at 07:34)</a>:</h4>
<p>If you want to write a performant library that uses SIMD now you also need to tell every user of your library to also build std</p>



<a name="226622118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622118">(Feb 17 2021 at 07:35)</a>:</h4>
<p>OK?</p>



<a name="226622123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622123">(Feb 17 2021 at 07:35)</a>:</h4>
<p>At that point it's easier to just use core::arch and makes stdsimd kind of useless, in my opinion</p>



<a name="226622188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622188">(Feb 17 2021 at 07:36)</a>:</h4>
<p>Well, so the entire promise of this part lf the api is that users don't have to mess with target_feature. it should literally "just work", and if <code>f32x4</code> doesn't work right when you try to use it on its own without any fancy attributes and multi-versioning and feature detection then we've given the users a lemon</p>



<a name="226622192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622192">(Feb 17 2021 at 07:36)</a>:</h4>
<p>a lot of people are out there writing <code>#![no_std]</code> projects, just saying that building std isn't that weird.</p>



<a name="226622220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622220">(Feb 17 2021 at 07:37)</a>:</h4>
<p>I don't see how building std is related to no_std? Isn't it the opposite?</p>



<a name="226622243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622243">(Feb 17 2021 at 07:37)</a>:</h4>
<p>exactly.</p>



<a name="226622261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622261">(Feb 17 2021 at 07:37)</a>:</h4>
<p>well, so hold on, build-std is also how you make cargo build core and alloc for you</p>



<a name="226622332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622332">(Feb 17 2021 at 07:38)</a>:</h4>
<p>build-std actually accepts a list of standard library crates to build</p>



<a name="226622345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622345">(Feb 17 2021 at 07:38)</a>:</h4>
<p>or i think just does them all if you leave off the list</p>



<a name="226622370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622370">(Feb 17 2021 at 07:39)</a>:</h4>
<p>I think we're getting way off in the weeds on this honestly</p>



<a name="226622380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622380">(Feb 17 2021 at 07:39)</a>:</h4>
<p>...could we make building with a target SIMD feature also imply Zbuild-std=simd?</p>



<a name="226622398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622398">(Feb 17 2021 at 07:39)</a>:</h4>
<p>it can't be that easy<br>
can it?</p>



<a name="226622441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622441">(Feb 17 2021 at 07:40)</a>:</h4>
<p>If we're only talking about supporting the base architecture why are we supporting anything other than x86-64 and aarch64? Nothing else afaik has SIMD in the base instruction set</p>



<a name="226622447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622447">(Feb 17 2021 at 07:40)</a>:</h4>
<p>telling cargo to build you your own <code>core</code> would make conditional compilation within <code>core</code> work right such that you could call the llvm simd_ceil (and friends) or not</p>



<a name="226622456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622456">(Feb 17 2021 at 07:40)</a>:</h4>
<p>armv7 certainly does not</p>



<a name="226622463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622463">(Feb 17 2021 at 07:40)</a>:</h4>
<p>Nor i386</p>



<a name="226622509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622509">(Feb 17 2021 at 07:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226622398">said</a>:</p>
<blockquote>
<p>it can't be that easy<br>
can it?</p>
</blockquote>
<p>i mean, i'm unsure that actually solves the problem. note that we probably dont want to tell people to say -Ctarget-feature or -Ctarget-cpu without solving <a href="https://github.com/rust-lang/rust/issues/64609">https://github.com/rust-lang/rust/issues/64609</a>, which kinda seems unsolvable tbh</p>



<a name="226622578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622578">(Feb 17 2021 at 07:42)</a>:</h4>
<p>I also think going entirely on compile-time features and just dismissing runtime feature selection is just a bad idea</p>



<a name="226622593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622593">(Feb 17 2021 at 07:42)</a>:</h4>
<p>well i misunderstood how inline and conditional compilation and inlining in a target crate interacted because i didn't think about it hard enough, also i didn't think about the core being pre-built well enough</p>



<a name="226622595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622595">(Feb 17 2021 at 07:42)</a>:</h4>
<p>Ripgrep is the tool that got me to learn rust in the first place...</p>



<a name="226622605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622605">(Feb 17 2021 at 07:42)</a>:</h4>
<p>none of this is an issue for <code>wide</code>, for example</p>



<a name="226622643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622643">(Feb 17 2021 at 07:43)</a>:</h4>
<p>ripgrep has a lot of conditional compilation tho'?</p>



<a name="226622646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622646">(Feb 17 2021 at 07:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226622578">said</a>:</p>
<blockquote>
<p>I also think going entirely on compile-time features and just dismissing runtime feature selection is just a bad idea</p>
</blockquote>
<p>both are important, but proper use of runtime feature selection will probably require unsafe code for quite a while, and so most users of the shiny new portable api will likely avoid it.</p>



<a name="226622652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622652">(Feb 17 2021 at 07:43)</a>:</h4>
<p>Well maybe it does but the magic is runtime feature selection</p>



<a name="226622661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622661">(Feb 17 2021 at 07:44)</a>:</h4>
<p>A pure sse2 ripgrep is certainly not as fast</p>



<a name="226622713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622713">(Feb 17 2021 at 07:44)</a>:</h4>
<p>Or my <code>multiversion</code> crate which is a safe abstraction <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="226622718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622718">(Feb 17 2021 at 07:44)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> that issue is only a problem if you don't build-std</p>



<a name="226622720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622720">(Feb 17 2021 at 07:44)</a>:</h4>
<p>But yes, it requires one unsafe block</p>



<a name="226622742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622742">(Feb 17 2021 at 07:45)</a>:</h4>
<p>and a million hearts shattered</p>



<a name="226622750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622750">(Feb 17 2021 at 07:45)</a>:</h4>
<p>you realize that 1 unsafe block is still a big deal for a lot of crates.</p>



<a name="226622779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622779">(Feb 17 2021 at 07:45)</a>:</h4>
<p>yeah most people would simply not do it</p>



<a name="226622793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622793">(Feb 17 2021 at 07:45)</a>:</h4>
<p>Properly vetted unsafe is correct rust</p>



<a name="226622839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622839">(Feb 17 2021 at 07:46)</a>:</h4>
<p>Which is why it's useful to have as an abstraction</p>



<a name="226622901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622901">(Feb 17 2021 at 07:47)</a>:</h4>
<p>I don't actually see how -Zbuild-std is more onerous than -Ctarget-feature. Like genuinely.</p>



<a name="226622914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622914">(Feb 17 2021 at 07:47)</a>:</h4>
<p>yes, i know, and I'm the kind of person who writes programs that start with <code>fn main() { unsafe {</code>, but most people are still very very uncomfortable with the idea of using unsafe themselves.</p>
<p>they want "only safe apis", and they don't think about the fact that everything a slice or a vec does is all unsafe all over the place</p>



<a name="226622971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622971">(Feb 17 2021 at 07:48)</a>:</h4>
<p>er, that was to C not J</p>



<a name="226622985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226622985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226622985">(Feb 17 2021 at 07:48)</a>:</h4>
<p>It's not, it's that it's more onerous than (and actually defeats) #[target_feature] which is already part of the language and should be supported</p>



<a name="226623001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623001">(Feb 17 2021 at 07:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226622901">said</a>:</p>
<blockquote>
<p>I don't actually see how -Zbuild-std is more onerous than -Ctarget-feature. Like genuinely.</p>
</blockquote>
<p>It's not, (aside from needing nightly, which I'm assuming we're imagining a world in which this is stable — ignoring for a fact that there are major problems with -Zbuild-std that need to be worked out before it <em>can</em> stabilize...) but nobody uses that anyway</p>



<a name="226623008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623008">(Feb 17 2021 at 07:49)</a>:</h4>
<p>actually you need both</p>



<a name="226623027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623027">(Feb 17 2021 at 07:49)</a>:</h4>
<p>you'd need to build std with a higher feature level enabled</p>



<a name="226623116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623116">(Feb 17 2021 at 07:50)</a>:</h4>
<p>but then the whole binary would require that level, hm, which negates multi-versioning</p>



<a name="226623175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623175">(Feb 17 2021 at 07:51)</a>:</h4>
<p>I'm extremely concerned about effectively limiting ourselves to only two instruction sets, SSE2 and ASIMD</p>



<a name="226623188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623188">(Feb 17 2021 at 07:51)</a>:</h4>
<p>wait, no, because of target_feature_enable, it would, uh, i think all work</p>



<a name="226623234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623234">(Feb 17 2021 at 07:52)</a>:</h4>
<p>gonna huff some noble gases to get the inspiration to solve this problem (no)</p>



<a name="226623251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623251">(Feb 17 2021 at 07:52)</a>:</h4>
<p>I still think this is a codegen problem</p>



<a name="226623267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623267">(Feb 17 2021 at 07:52)</a>:</h4>
<p>well it's all a codegen problem</p>



<a name="226623275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623275">(Feb 17 2021 at 07:52)</a>:</h4>
<p>It's primarily an LLVM bug for poorly implementing vector rounding etc</p>



<a name="226623295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623295">(Feb 17 2021 at 07:53)</a>:</h4>
<p>going to WRITE MY OWN BACKEND AT THIS RATE</p>



<a name="226623300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623300">(Feb 17 2021 at 07:53)</a>:</h4>
<p>GO UTTERLY MAD</p>



<a name="226623312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623312">(Feb 17 2021 at 07:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226623175">said</a>:</p>
<blockquote>
<p>I'm extremely concerned about effectively limiting ourselves to only two instruction sets, SSE2 and ASIMD</p>
</blockquote>
<p>And I'm extremely concerned about optimizing for the case where people just use the library without:</p>
<ul>
<li>Adding target feature flags</li>
<li>writing unsafe code</li>
<li>using multiversioning</li>
</ul>
<p>Which seems like it would be very common</p>



<a name="226623404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623404">(Feb 17 2021 at 07:54)</a>:</h4>
<p>Which other part of the stdlib requires that much work to "use correctly"?</p>



<a name="226623448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623448">(Feb 17 2021 at 07:54)</a>:</h4>
<p>nada, basically, except on special platforms... which is why I think -Zbuild-std is actually relatively OK.</p>



<a name="226623466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623466">(Feb 17 2021 at 07:55)</a>:</h4>
<p>Maybe the fact that liballoc perf is harmed by not using a custom allocator? But it still optimizes for the default allocator case...</p>



<a name="226623487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623487">(Feb 17 2021 at 07:55)</a>:</h4>
<p>since you kinda need to do that kinda thing for genuinely special platforms anyways</p>



<a name="226623507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623507">(Feb 17 2021 at 07:56)</a>:</h4>
<p>so, so, does cfg and multi-versioning interact right?</p>



<a name="226623551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623551">(Feb 17 2021 at 07:56)</a>:</h4>
<p>In that case we shouldn't even be very concerned about shuffles since extract, insert, movldup and blendv aren't part of SSE2</p>



<a name="226623569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623569">(Feb 17 2021 at 07:56)</a>:</h4>
<p>you can do a low cost blend with sse2</p>



<a name="226623575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623575">(Feb 17 2021 at 07:56)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> no they do not, cfg occurs textually before lowering, target feature operates at codegen</p>



<a name="226623577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623577">(Feb 17 2021 at 07:56)</a>:</h4>
<p>it's not so bad</p>



<a name="226623579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623579">(Feb 17 2021 at 07:56)</a>:</h4>
<p>pshufb!</p>



<a name="226623595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623595">(Feb 17 2021 at 07:57)</a>:</h4>
<p>wait that's sse3</p>



<a name="226623596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623596">(Feb 17 2021 at 07:57)</a>:</h4>
<p>Which is why I really do not thing cfg is appropriate for this</p>



<a name="226623627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623627">(Feb 17 2021 at 07:57)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> well that's absolutely beyond the pale bad and stabs multi-versioning in the face</p>



<a name="226623680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623680">(Feb 17 2021 at 07:58)</a>:</h4>
<p>I think that's just not what cfg is for</p>



<a name="226623713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623713">(Feb 17 2021 at 07:59)</a>:</h4>
<p>so, but wait, if you target_feature(enable=sse3) on a function then the cfg of sse3 is still false inside that function?</p>



<a name="226623716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623716">(Feb 17 2021 at 07:59)</a>:</h4>
<p>You would need to delay lexing a function until you've finished codegen of another</p>



<a name="226623747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623747">(Feb 17 2021 at 07:59)</a>:</h4>
<p>Yes, because cfg is set before even lowering to HIR</p>



<a name="226623765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623765">(Feb 17 2021 at 07:59)</a>:</h4>
<p>that is utterly broken</p>



<a name="226623766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623766">(Feb 17 2021 at 07:59)</a>:</h4>
<p>cfg is purely a preprocessor</p>



<a name="226623963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226623963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226623963">(Feb 17 2021 at 08:00)</a>:</h4>
<p>wait, you're answering questions about cfg, not target_feature(enable)</p>



<a name="226624096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624096">(Feb 17 2021 at 08:01)</a>:</h4>
<p>The target feature attribute purely affects codegen</p>



<a name="226624207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624207">(Feb 17 2021 at 08:02)</a>:</h4>
<p>ssso...</p>



<a name="226624243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624243">(Feb 17 2021 at 08:02)</a>:</h4>
<p>cfg is handled by rustc sometime around lexing, and the target feature attribute is hardly considered by rust at all and goes almost directly to LLVM</p>



<a name="226624250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624250">(Feb 17 2021 at 08:02)</a>:</h4>
<p>so you can't use <code>#[cfg(target_feature="sse3")]</code>, but you <em>could</em> use the cfg! version, right?</p>



<a name="226624256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624256">(Feb 17 2021 at 08:02)</a>:</h4>
<p>You can't use either</p>



<a name="226624267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624267">(Feb 17 2021 at 08:02)</a>:</h4>
<p>cfg is set before you even start the compilation process</p>



<a name="226624287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624287">(Feb 17 2021 at 08:02)</a>:</h4>
<p>oh right that's the same problem</p>



<a name="226624320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624320">(Feb 17 2021 at 08:03)</a>:</h4>
<p>alright time for the portable simd 3.0 rfc</p>



<a name="226624338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624338">(Feb 17 2021 at 08:03)</a>:</h4>
<p>That's why I'm suggesting it's an LLVM bug</p>



<a name="226624357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624357">(Feb 17 2021 at 08:03)</a>:</h4>
<p>ok, I'm going to go to bed, we've had a nice winemaking session but tomorrow we're gonna squeeze these grapes of wrath and get a real write up.</p>



<a name="226624412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624412">(Feb 17 2021 at 08:04)</a>:</h4>
<p>Only LLVM is aware of the target features available at the codegen site, it's up to LLVM to produce good code for its own instructions</p>



<a name="226624419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624419">(Feb 17 2021 at 08:04)</a>:</h4>
<p>or something. maybe later this/next week.</p>



<a name="226624426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624426">(Feb 17 2021 at 08:04)</a>:</h4>
<p>i think llvm is at fault but also rustc is at fault on the target feature enabled thing</p>



<a name="226624430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BlackHoleFox <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624430">(Feb 17 2021 at 08:04)</a>:</h4>
<p>As a bystander, I just feel like noting that I'd rather not build the standard library to use SIMD. Compile times are already bad enough with Rust and that would just make it worse.</p>



<a name="226624493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624493">(Feb 17 2021 at 08:05)</a>:</h4>
<p>oh we can get the time to build <code>core</code> back down under a few minutes if we just cut some avx512 stuff &gt;.&gt;</p>



<a name="226624510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624510">(Feb 17 2021 at 08:05)</a>:</h4>
<p>lol.</p>



<a name="226624521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624521">(Feb 17 2021 at 08:06)</a>:</h4>
<p>delete intel</p>



<a name="226624569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226624569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226624569">(Feb 17 2021 at 08:06)</a>:</h4>
<p>sounds good to me.</p>



<a name="226625167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625167">(Feb 17 2021 at 08:12)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/55107">https://github.com/rust-lang/rust/issues/55107</a></p>



<a name="226625288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625288">(Feb 17 2021 at 08:13)</a>:</h4>
<p>Just found this issue of someone using #[target_feature] and roundps from 2018, so I really don't think I have a unique stance on #[target_feature]</p>



<a name="226625367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625367">(Feb 17 2021 at 08:14)</a>:</h4>
<p>(this issue also illustrates that the codegen issues here are definitely not new)</p>



<a name="226625389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625389">(Feb 17 2021 at 08:14)</a>:</h4>
<p>(unfortunately)</p>



<a name="226625399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625399">(Feb 17 2021 at 08:15)</a>:</h4>
<p>definitely going mad tho'</p>



<a name="226625411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625411">(Feb 17 2021 at 08:15)</a>:</h4>
<p>and considering writing my own backend</p>



<a name="226625452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625452">(Feb 17 2021 at 08:15)</a>:</h4>
<p>very "programming as Lovecraftian horror" project group, I like it.</p>



<a name="226625790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625790">(Feb 17 2021 at 08:19)</a>:</h4>
<p>( LET'S MULTIVERSION STD. no. maybe. )</p>



<a name="226625900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625900">(Feb 17 2021 at 08:20)</a>:</h4>
<p>If we had language level multiversioning that would possibly be the way to go</p>



<a name="226625923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226625923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226625923">(Feb 17 2021 at 08:21)</a>:</h4>
<p>Though at that point you could just do it at codegen</p>



<a name="226634208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226634208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226634208">(Feb 17 2021 at 09:49)</a>:</h4>
<p>hmm, it seems to me that the logical solution is to add code to LLVM that uses the Rust vector math library that is apparently going to be written since calling libm is unacceptable. This is just like clang's <code>-fvec-lib=...</code> option.<br>
<a href="https://reviews.llvm.org/D88154">https://reviews.llvm.org/D88154</a></p>



<a name="226659671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226659671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226659671">(Feb 17 2021 at 14:02)</a>:</h4>
<p>the thing about multi-versioning is that doing it at the individual op level is basically way too low level</p>



<a name="226660366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226660366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226660366">(Feb 17 2021 at 14:07)</a>:</h4>
<p>That's exactly what codegen does, though</p>



<a name="226661440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226661440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226661440">(Feb 17 2021 at 14:15)</a>:</h4>
<p>By multiversioning here I don't mean runtime dispatch</p>



<a name="226661474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226661474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226661474">(Feb 17 2021 at 14:15)</a>:</h4>
<p>I mean multiple versions of the function, one of which is selected by the codegen features</p>



<a name="226661647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226661647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226661647">(Feb 17 2021 at 14:16)</a>:</h4>
<p>I do think using libmvec looks like the best way to fix the immediate performance issue of libm, though</p>



<a name="226662528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226662528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226662528">(Feb 17 2021 at 14:22)</a>:</h4>
<p>what is the likelihood that people have it installed though?</p>



<a name="226662621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226662621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226662621">(Feb 17 2021 at 14:23)</a>:</h4>
<p>True. I'm really hoping there's a way to static link it</p>



<a name="226662789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226662789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226662789">(Feb 17 2021 at 14:24)</a>:</h4>
<p>It's also minimal enough that we can recreate it in rust</p>



<a name="226662807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226662807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226662807">(Feb 17 2021 at 14:24)</a>:</h4>
<p>Much smaller than libm</p>



<a name="226663638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226663638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226663638">(Feb 17 2021 at 14:30)</a>:</h4>
<p>We may be able to just add the symbol directly to core?  It would just be some FFI and the implementation itself could be done with stdsimd</p>



<a name="226666258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226666258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226666258">(Feb 17 2021 at 14:50)</a>:</h4>
<p>The problem with multi-versioning at the per function level is that it's a branch per function call instead of like, once at the start of a lot of work and then not again</p>



<a name="226666447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226666447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226666447">(Feb 17 2021 at 14:51)</a>:</h4>
<p>I don't mean runtime dispatch</p>



<a name="226666478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226666478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226666478">(Feb 17 2021 at 14:51)</a>:</h4>
<p>I wonder how the <code>-Z build-std</code> work is going.  It might be ok to make the compile-time global feature detection dependent on that.  (Though that won't solve the local-per-function parts for when Lokathor wants to have basic and fancy versions of the program and do a runtime choice between them.)</p>



<a name="226666603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226666603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226666603">(Feb 17 2021 at 14:52)</a>:</h4>
<p>I mean the exact same as what LLVM is doing--depending on the available features it chooses the correct codelet</p>



<a name="226666651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226666651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226666651">(Feb 17 2021 at 14:52)</a>:</h4>
<p>but also here's a fun fact, just a little detail i thought I'd mention: libm is used in the standard library by a slightly round-about way. What happens is that compiler-builtins has a git sub-module for libm which it can compile in and it doesn't even compile the libm crate as a crate, it just compiles the individual modules that are deemed necessary.</p>



<a name="226666676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226666676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226666676">(Feb 17 2021 at 14:52)</a>:</h4>
<p>Which brings me back to my point that I <em>really</em> think this is an LLVM issue</p>



<a name="226667030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667030">(Feb 17 2021 at 14:54)</a>:</h4>
<p>doesn't rust allow usage of an llvm like 2 versions behind the latest?</p>



<a name="226667108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667108">(Feb 17 2021 at 14:55)</a>:</h4>
<p>No clue</p>



<a name="226667132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667132">(Feb 17 2021 at 14:55)</a>:</h4>
<p>Seems likely</p>



<a name="226667286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667286">(Feb 17 2021 at 14:56)</a>:</h4>
<p>so like if you fixed it in LLVM <em>today</em> it'd be a year or whatever for that to be reflected in rustc?</p>



<a name="226667373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667373">(Feb 17 2021 at 14:56)</a>:</h4>
<p>Maybe</p>



<a name="226667400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667400">(Feb 17 2021 at 14:56)</a>:</h4>
<p>unfortunate</p>



<a name="226667618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667618">(Feb 17 2021 at 14:58)</a>:</h4>
<p>Though it seems there's libmvec support today</p>



<a name="226667819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667819">(Feb 17 2021 at 14:59)</a>:</h4>
<p>so we get llvm to emit libmvec calls instead of libm calls, and then we write any libmvec functions that aren't covered by the system libmvec?</p>



<a name="226667894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667894">(Feb 17 2021 at 14:59)</a>:</h4>
<p>Hopefully</p>



<a name="226667972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226667972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226667972">(Feb 17 2021 at 15:00)</a>:</h4>
<p>well <em>that</em> sound quite doable</p>



<a name="226668028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226668028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226668028">(Feb 17 2021 at 15:00)</a>:</h4>
<p>My only concern is that libmvec seems to be a specific gnu thing</p>



<a name="226668090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226668090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226668090">(Feb 17 2021 at 15:00)</a>:</h4>
<p>Though I've seen at least one non-gnu implementation</p>



<a name="226668152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226668152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226668152">(Feb 17 2021 at 15:01)</a>:</h4>
<p>we would need to write our own probably</p>



<a name="226668184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226668184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226668184">(Feb 17 2021 at 15:01)</a>:</h4>
<p>Yeah</p>



<a name="226668358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226668358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226668358">(Feb 17 2021 at 15:02)</a>:</h4>
<p>I still think our time is best spent elsewhere for now and just use the slower libm implementation</p>



<a name="226668402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226668402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226668402">(Feb 17 2021 at 15:02)</a>:</h4>
<p>But we should at least check clang on godbolt to see what it actually emits</p>



<a name="226676207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226676207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226676207">(Feb 17 2021 at 15:49)</a>:</h4>
<p>go for it. <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="226679183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226679183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226679183">(Feb 17 2021 at 16:03)</a>:</h4>
<p>libmvec seems to be x86_64 only also</p>



<a name="226679281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226679281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226679281">(Feb 17 2021 at 16:03)</a>:</h4>
<p>but maybe the docs i see on it are outdated</p>



<a name="226682273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226682273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226682273">(Feb 17 2021 at 16:20)</a>:</h4>
<p>Yeah libmvec is x86_64 only apparently</p>



<a name="226682359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226682359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226682359">(Feb 17 2021 at 16:20)</a>:</h4>
<p>The good news, though, is llvm actually lets us choose our vector library</p>



<a name="226682424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226682424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226682424">(Feb 17 2021 at 16:20)</a>:</h4>
<p>It supports libmvec, Apple Accelerate, IBM MASS, and Intel SVML</p>



<a name="226682506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226682506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226682506">(Feb 17 2021 at 16:21)</a>:</h4>
<p>And yes, it does produce function calls to those instead of libm</p>



<a name="226682550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226682550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226682550">(Feb 17 2021 at 16:21)</a>:</h4>
<p>It appears right now only a subset of functions are supported (round is not one of them)</p>



<a name="226682637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226682637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226682637">(Feb 17 2021 at 16:22)</a>:</h4>
<p>It supports sin, cos, exp, pow, and log which is a good start</p>



<a name="226682744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226682744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226682744">(Feb 17 2021 at 16:22)</a>:</h4>
<p>But the thing that is most exciting to me is that if they support so many... Perhaps we can just write our own and add it as one of the many supported libraries?</p>



<a name="226683025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226683025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226683025">(Feb 17 2021 at 16:24)</a>:</h4>
<p>(though if we're really just filling out an API we can do that too)</p>



<a name="226683280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226683280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226683280">(Feb 17 2021 at 16:26)</a>:</h4>
<p><a href="https://gcc.godbolt.org/z/Tq43b4">https://gcc.godbolt.org/z/Tq43b4</a></p>



<a name="226683354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226683354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226683354">(Feb 17 2021 at 16:26)</a>:</h4>
<p>despite libmvec being x86_64, it appears to allow it to be used on aarch64!</p>



<a name="226683391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226683391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226683391">(Feb 17 2021 at 16:27)</a>:</h4>
<p>so I think we can just fill out the libmvec API.</p>



<a name="226683884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226683884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226683884">(Feb 17 2021 at 16:29)</a>:</h4>
<p>sounds promising.</p>



<a name="226684404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226684404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226684404">(Feb 17 2021 at 16:32)</a>:</h4>
<p><a href="https://gcc.godbolt.org/z/xrsM84">https://gcc.godbolt.org/z/xrsM84</a></p>



<a name="226684430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226684430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226684430">(Feb 17 2021 at 16:32)</a>:</h4>
<p>and if you actually provide that symbol, it will use it!</p>



<a name="226684489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226684489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226684489">(Feb 17 2021 at 16:32)</a>:</h4>
<p>obviously that's not actually a round function, but it's a good proof of concept that it can be overridden!</p>



<a name="226684643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226684643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226684643">(Feb 17 2021 at 16:33)</a>:</h4>
<p>Uhhh, tourist question here - but do we have pros/cons of the different vector libraries? Does LLVM not support the Agner Fog one?</p>



<a name="226684848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226684848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226684848">(Feb 17 2021 at 16:34)</a>:</h4>
<p>these vector libraries are not intended for direct user access, really, they're intended for the compiler to call to implement things like libc</p>



<a name="226684923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226684923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226684923">(Feb 17 2021 at 16:35)</a>:</h4>
<p>agner fog's library is something to help users, not compilers (and presumably builds on top of whatever the compiler does, which may include using these libraries)</p>



<a name="226685039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226685039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226685039">(Feb 17 2021 at 16:36)</a>:</h4>
<p>in terms of different vector libraries svml is a very popular one</p>



<a name="226685072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226685072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226685072">(Feb 17 2021 at 16:36)</a>:</h4>
<p>but it's a vendor library from Intel</p>



<a name="226685147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226685147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226685147">(Feb 17 2021 at 16:36)</a>:</h4>
<p>libmvec is probably the most appropriate for us (though I think we could actually use Accelerate on macOS)</p>



<a name="226685370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226685370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226685370">(Feb 17 2021 at 16:38)</a>:</h4>
<p>maybe I'm being too optimistic but I think we may be able to avoid a compiler PR altogether if there's a way to access that LLVM option from cargo! but if not we can PR the compiler to add it...</p>



<a name="226685481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226685481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226685481">(Feb 17 2021 at 16:39)</a>:</h4>
<p>and we can start a libmvec crate in the stdsimd repo that we include to provide the intrinsics</p>



<a name="226685529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226685529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226685529">(Feb 17 2021 at 16:39)</a>:</h4>
<p>cautiously optimistic</p>



<a name="226686308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226686308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226686308">(Feb 17 2021 at 16:44)</a>:</h4>
<p>ooh there is in fact <code>-C llvm-args=</code> which we can add to a <code>.cargo/config</code></p>



<a name="226690972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226690972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226690972">(Feb 17 2021 at 17:12)</a>:</h4>
<p>FWIW ... Julia did end up writing a julia version of libm because of similar issues</p>



<a name="226691079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226691079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226691079">(Feb 17 2021 at 17:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226686308">said</a>:</p>
<blockquote>
<p>ooh there is in fact <code>-C llvm-args=</code> which we can add to a <code>.cargo/config</code></p>
</blockquote>
<p>If it's required for good performance we should try to make it more automatic than .cargo/config. </p>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226685481">said</a>:</p>
<blockquote>
<p>and we can start a libmvec crate in the stdsimd repo that we include to provide the intrinsics</p>
</blockquote>
<p>I'm in favor of this for several reasons, but largerly: it would help kick the tires using the API in a plausible setting that it should be complete enough to support.</p>



<a name="226691299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226691299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226691299">(Feb 17 2021 at 17:14)</a>:</h4>
<p>I agree it should maybe be marginally more automatic? But as it currently stands only stdsimd will really be capable of generating calls to libmvec in the first place.</p>



<a name="226691697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226691697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226691697">(Feb 17 2021 at 17:16)</a>:</h4>
<p>those flags would need to be present in the <code>.cargo/config</code>/<code>RUSTFLAGS</code> of the builder, so the fact that we're the ones that generate the calls doesn't really make a difference.</p>



<a name="226691788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226691788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226691788">(Feb 17 2021 at 17:17)</a>:</h4>
<p>Does cargo not use that for dependencies?  In that case we will need to handle it when building core</p>



<a name="226691931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226691931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226691931">(Feb 17 2021 at 17:18)</a>:</h4>
<p>yeah only the end-user (well, the builders) <code>.cargo/config</code> is used</p>



<a name="226691964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226691964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226691964">(Feb 17 2021 at 17:18)</a>:</h4>
<p>Gotcha</p>



<a name="226692025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226692025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226692025">(Feb 17 2021 at 17:19)</a>:</h4>
<p>(its intentionally not supported to have dependencies modify it)</p>



<a name="226692075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226692075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226692075">(Feb 17 2021 at 17:19)</a>:</h4>
<p>On an unrelated topic, libmvec doesn't provide rounding, so rounding will use libm no matter what unless we bring our own vector lib to LLVM</p>



<a name="226703630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226703630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226703630">(Feb 17 2021 at 18:33)</a>:</h4>
<p>So, problem 0:<br>
  core must compile without any non-Rust dependencies</p>



<a name="226703855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226703855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226703855">(Feb 17 2021 at 18:34)</a>:</h4>
<p>that's a "minor" code writing issue</p>



<a name="226704520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704520">(Feb 17 2021 at 18:39)</a>:</h4>
<p>1: core is precompiled for a target, and that code is then taken and inserted into Rust compilation, so if our crate gets pushed into core, we have to recompile it, effectively, in order to insert code for different features.</p>



<a name="226704614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704614">(Feb 17 2021 at 18:39)</a>:</h4>
<p>This code is only fallback code, it doesn't use any target features</p>



<a name="226704690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704690">(Feb 17 2021 at 18:40)</a>:</h4>
<p>LLVM will use the correct instruction instead of libm if it is possible</p>



<a name="226704694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704694">(Feb 17 2021 at 18:40)</a>:</h4>
<p>what is "this"</p>



<a name="226704700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704700">(Feb 17 2021 at 18:40)</a>:</h4>
<p>I am not an OO programmer</p>



<a name="226704706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704706">(Feb 17 2021 at 18:40)</a>:</h4>
<p>I do not remember what "this" is.</p>



<a name="226704711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704711">(Feb 17 2021 at 18:40)</a>:</h4>
<p>libm/libmvec</p>



<a name="226704760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704760">(Feb 17 2021 at 18:40)</a>:</h4>
<p>Also I think the intention is to write the ~5 libmvec functions in rust</p>



<a name="226704789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704789">(Feb 17 2021 at 18:41)</a>:</h4>
<p>I have no intentions yet.</p>



<a name="226704814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704814">(Feb 17 2021 at 18:41)</a>:</h4>
<p>The intention of my plan I am exploring, I mean</p>



<a name="226704859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704859">(Feb 17 2021 at 18:41)</a>:</h4>
<p>And I do not believe that is what is happening, I believe what LLVM is doing is taking rustc's emitted LLVM instructions which it then resolves to different compilations based on what options are available, and that one of those compilations is to resolve the LLVM instructions into libm calls.</p>



<a name="226704937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704937">(Feb 17 2021 at 18:42)</a>:</h4>
<p>I am, for the moment, setting aside libmvec.</p>



<a name="226704975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226704975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226704975">(Feb 17 2021 at 18:42)</a>:</h4>
<p>Or well, I will get to it in a moment from now, I want to understand the problem fully before jumping into any solutions.</p>



<a name="226705041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705041">(Feb 17 2021 at 18:43)</a>:</h4>
<p>I don't believe that's what's happening</p>



<a name="226705075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705075">(Feb 17 2021 at 18:43)</a>:</h4>
<p>But go on</p>



<a name="226705121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705121">(Feb 17 2021 at 18:43)</a>:</h4>
<p>Please explain to me what you think the rustc+LLVM compilation model is for this, then.</p>



<a name="226705290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705290">(Feb 17 2021 at 18:44)</a>:</h4>
<p>I explored this entirely in llc from LLVM IR to asm, no rustc involved</p>



<a name="226705315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705315">(Feb 17 2021 at 18:44)</a>:</h4>
<p><em>nods</em></p>



<a name="226705330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705330">(Feb 17 2021 at 18:45)</a>:</h4>
<p>LLVM is lowering instructions to asm, let's choose sin as an example</p>



<a name="226705366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705366">(Feb 17 2021 at 18:45)</a>:</h4>
<p>If you have the appropriate feature it will use the hardware instruction for sin</p>



<a name="226705399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705399">(Feb 17 2021 at 18:45)</a>:</h4>
<p>If you do not it will use libm (or libmvec, if you have that enabled)</p>



<a name="226705443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705443">(Feb 17 2021 at 18:45)</a>:</h4>
<p>That is what I thought, where do you think my explanation differs?</p>



<a name="226705588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705588">(Feb 17 2021 at 18:46)</a>:</h4>
<p>Reading again I think I maybe misunderstood, you meant "potential compilations" not actual compilations?</p>



<a name="226705601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705601">(Feb 17 2021 at 18:46)</a>:</h4>
<p>Yes.</p>



<a name="226705641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226705641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226705641">(Feb 17 2021 at 18:47)</a>:</h4>
<p>Okay then nevermind, yes I think we're on the same page</p>



<a name="226706225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226706225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226706225">(Feb 17 2021 at 18:51)</a>:</h4>
<p>What do you mean by problem 1? 0 I understand</p>



<a name="226706653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226706653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226706653">(Feb 17 2021 at 18:54)</a>:</h4>
<p>My understanding is that much of the problem is that when we ship std, we ship assembly code that can be reused during compile and link time, so if we ship core for x86_64, it will have been compiled for SSE2, and so an invocation using SSE4 as a target feature would either link SSE2 code or require rebuilding std.</p>



<a name="226706805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226706805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226706805">(Feb 17 2021 at 18:55)</a>:</h4>
<p>And really I mean "libstd" which is the entirety of<br>
core<br>
alloc<br>
std<br>
and possibly other things.</p>



<a name="226706891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226706891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226706891">(Feb 17 2021 at 18:55)</a>:</h4>
<p>I actually personally think that's not the problem. I think that's a problem with a particular workaround</p>



<a name="226706968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226706968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226706968">(Feb 17 2021 at 18:56)</a>:</h4>
<p>std etc <em>should</em> only be built for the base features</p>



<a name="226707029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707029">(Feb 17 2021 at 18:56)</a>:</h4>
<p>Nonetheless, it is a <strong>constraint</strong></p>



<a name="226707046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707046">(Feb 17 2021 at 18:56)</a>:</h4>
<p>Agreed</p>



<a name="226707059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707059">(Feb 17 2021 at 18:56)</a>:</h4>
<p>Well</p>



<a name="226707110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707110">(Feb 17 2021 at 18:56)</a>:</h4>
<p>Many of these are problems that only defeat or require rerouting of "naive" solutions.</p>



<a name="226707130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707130">(Feb 17 2021 at 18:57)</a>:</h4>
<p>I would argue that it's only a constraint to certain types of code.  Inline intrinsics get passed to codegen and don't suffer from that</p>



<a name="226707163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707163">(Feb 17 2021 at 18:57)</a>:</h4>
<p>Go on?</p>



<a name="226707349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707349">(Feb 17 2021 at 18:58)</a>:</h4>
<p>Well it's everything we're already relying on. <code>simd_add</code> lowers to LLVM <code>fadd</code>, and we mark <code>Add::add</code> inline so codegen occurs outside of <code>core</code></p>



<a name="226707399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707399">(Feb 17 2021 at 18:58)</a>:</h4>
<p>Is that as simple as #[inline]?</p>



<a name="226707411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707411">(Feb 17 2021 at 18:58)</a>:</h4>
<p>So <code>fadd</code> is free to lower to the appropriate target features</p>



<a name="226707423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707423">(Feb 17 2021 at 18:58)</a>:</h4>
<p>Yep.</p>



<a name="226707464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707464">(Feb 17 2021 at 18:59)</a>:</h4>
<p>Inline basically says that MIR ends up in the crate instead of asm</p>



<a name="226707472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707472">(Feb 17 2021 at 18:59)</a>:</h4>
<p>...so this is not a problem at all except that it pushes us out of core?</p>



<a name="226707542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707542">(Feb 17 2021 at 18:59)</a>:</h4>
<p>Well, no, there are the issues Lokathor mentioned.</p>



<a name="226707550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707550">(Feb 17 2021 at 18:59)</a>:</h4>
<p>Well there's also the performance concern as well</p>



<a name="226707738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707738">(Feb 17 2021 at 19:00)</a>:</h4>
<p>Right, so, problem 2: this is suck-ass bullshit when it comes to speed of execution.</p>



<a name="226707966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226707966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226707966">(Feb 17 2021 at 19:02)</a>:</h4>
<p>It's actually not <em>that</em> bad as far as I can tell</p>



<a name="226708006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708006">(Feb 17 2021 at 19:02)</a>:</h4>
<p>For f64 it's probably only 2x slower</p>



<a name="226708021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708021">(Feb 17 2021 at 19:02)</a>:</h4>
<p>and f32s?</p>



<a name="226708023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708023">(Feb 17 2021 at 19:02)</a>:</h4>
<p>Which of course I want fixed</p>



<a name="226708035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708035">(Feb 17 2021 at 19:02)</a>:</h4>
<p>Nonetheless, a "pessimized" SSE2 vector implementation for many things which <strong>do not</strong> have dedicated hardware instructions can still handily defeat the scalar libm calls in many cases.</p>



<a name="226708037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708037">(Feb 17 2021 at 19:02)</a>:</h4>
<p>4x for f32</p>



<a name="226708054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708054">(Feb 17 2021 at 19:02)</a>:</h4>
<p>4x is really bad.</p>



<a name="226708102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708102">(Feb 17 2021 at 19:03)</a>:</h4>
<p>It's not nearly as bad as the 100x+ worse performance you'll get using AVX</p>



<a name="226708150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708150">(Feb 17 2021 at 19:03)</a>:</h4>
<p>is it really 100x</p>



<a name="226708162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708162">(Feb 17 2021 at 19:03)</a>:</h4>
<p>have we benched it.</p>



<a name="226708163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708163">(Feb 17 2021 at 19:03)</a>:</h4>
<p>Fwiw I want both fixed and I think that's doable</p>



<a name="226708167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708167">(Feb 17 2021 at 19:03)</a>:</h4>
<p>Yes</p>



<a name="226708182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708182">(Feb 17 2021 at 19:03)</a>:</h4>
<p>Okay, you've benched it?</p>



<a name="226708190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708190">(Feb 17 2021 at 19:03)</a>:</h4>
<p>Can I see the code, please?</p>



<a name="226708334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708334">(Feb 17 2021 at 19:04)</a>:</h4>
<p>I am fully 100% prepared to believe you, I am not even doubting, I just want to be able to put all these ducks in a row.</p>



<a name="226708397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708397">(Feb 17 2021 at 19:04)</a>:</h4>
<p>No but I can explain it pretty simply I think.  roundps/vroundps is 1x throughput, 8 cycle latency which is pretty standard for a floating point instruction</p>



<a name="226708443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708443">(Feb 17 2021 at 19:04)</a>:</h4>
<p>About the same as a single addition</p>



<a name="226708492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708492">(Feb 17 2021 at 19:05)</a>:</h4>
<p>Okay okay no, sorry, I should be precise:<br>
I believe <strong>you</strong>, and your experience, but I do not believe x86.</p>



<a name="226708549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708549">(Feb 17 2021 at 19:05)</a>:</h4>
<p>If you look at an implementation for libc round it's dramatically more instructions than a single float op</p>



<a name="226708597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708597">(Feb 17 2021 at 19:05)</a>:</h4>
<p>Well yes, but all those get shredded into micro-ops.</p>



<a name="226708621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708621">(Feb 17 2021 at 19:06)</a>:</h4>
<p>The numbers for throughput and latency are the microops actually</p>



<a name="226708696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708696">(Feb 17 2021 at 19:06)</a>:</h4>
<p>The throughput is related to the number of load ports and the latency is how long the microops take</p>



<a name="226708699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708699">(Feb 17 2021 at 19:06)</a>:</h4>
<p>And the latency thing varies from chip to chip, which is why I want benches so I can run them on my computer or someone else's computer.</p>



<a name="226708809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708809">(Feb 17 2021 at 19:07)</a>:</h4>
<p>note that libmvec can be used via llvm autovectorization, as in the following example:<br>
<a href="https://gcc.godbolt.org/z/qPrW9v">https://gcc.godbolt.org/z/qPrW9v</a></p>



<a name="226708851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708851">(Feb 17 2021 at 19:07)</a>:</h4>
<p>Agreed but my point is even if the latency was like 30, which is ridiculous, it's still much much faster than an SSE2 implementation</p>



<a name="226708928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708928">(Feb 17 2021 at 19:07)</a>:</h4>
<p>I know, I just want to know actual proportions.</p>



<a name="226708938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708938">(Feb 17 2021 at 19:07)</a>:</h4>
<p>The throughput alone will limit you to dozens of cycles, discounting the latency</p>



<a name="226708949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226708949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226708949">(Feb 17 2021 at 19:07)</a>:</h4>
<p>As opposed to "x100, spitballing"</p>



<a name="226709047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709047">(Feb 17 2021 at 19:08)</a>:</h4>
<p>Well I looked at the implementations of a few libcs and it's dozens of ops</p>



<a name="226709201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709201">(Feb 17 2021 at 19:09)</a>:</h4>
<p>And all float ops other than like sqrt are approximately the same</p>



<a name="226709288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709288">(Feb 17 2021 at 19:09)</a>:</h4>
<p>abs</p>



<a name="226709309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709309">(Feb 17 2021 at 19:10)</a>:</h4>
<p>I remember that one.</p>



<a name="226709463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709463">(Feb 17 2021 at 19:10)</a>:</h4>
<p>SSE doesn't have abs, you just mask off the sign bit</p>



<a name="226709478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709478">(Feb 17 2021 at 19:10)</a>:</h4>
<p>Unless that's what you mean</p>



<a name="226709653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709653">(Feb 17 2021 at 19:11)</a>:</h4>
<p>4x and 100x are both made up numbers until we bench. either number could be worse. i suspect in practice sse2 is actually worse than a 4x loss because there's a pipelining loss too, which incidentally won't show up in simple benchmarks that don't have a pipeline of work.</p>



<a name="226709761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709761">(Feb 17 2021 at 19:12)</a>:</h4>
<p>yes.</p>



<a name="226709790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709790">(Feb 17 2021 at 19:12)</a>:</h4>
<div class="codehilite" data-code-language="GAS"><pre><span></span><code><span class="nl">example:</span><span class="err">:</span><span class="nl">f32x4:</span><span class="err">:</span><span class="nl">abs:</span>
        <span class="nf">movq</span>    <span class="nv">%rdi</span><span class="p">,</span> <span class="nv">%rax</span>
        <span class="nf">movaps</span>  <span class="p">(</span><span class="nv">%rsi</span><span class="p">),</span> <span class="nv">%xmm0</span>
        <span class="nf">andps</span>   <span class="no">.LCPI13_0</span><span class="p">(</span><span class="nv">%rip</span><span class="p">),</span> <span class="nv">%xmm0</span>
        <span class="nf">movaps</span>  <span class="nv">%xmm0</span><span class="p">,</span> <span class="p">(</span><span class="nv">%rdi</span><span class="p">)</span>
        <span class="nf">retq</span>
</code></pre></div>



<a name="226709795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709795">(Feb 17 2021 at 19:12)</a>:</h4>
<p>Yeah, that's kind of why I didn't want to benchmark</p>



<a name="226709816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709816">(Feb 17 2021 at 19:12)</a>:</h4>
<p>It's exceptionally difficult to make a good one</p>



<a name="226709934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226709934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226709934">(Feb 17 2021 at 19:13)</a>:</h4>
<p>Correct.<br>
But even an acceptable microbenchmark would put us on more solid footing.</p>



<a name="226710091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710091">(Feb 17 2021 at 19:14)</a>:</h4>
<p>Fwiw all float ops in SSE have a throughput of 1 so the number of operations is a lower bound on the performance, not an upper bound</p>



<a name="226710130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710130">(Feb 17 2021 at 19:14)</a>:</h4>
<p>The data dependencies will only increase it due to the latencies</p>



<a name="226710358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710358">(Feb 17 2021 at 19:16)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> Interesting.</p>



<a name="226710452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710452">(Feb 17 2021 at 19:16)</a>:</h4>
<p>note that rounding is actually cheapish: <a href="https://github.com/Lokathor/wide/blob/main/src/f32x4_.rs#L473">https://github.com/Lokathor/wide/blob/main/src/f32x4_.rs#L473</a></p>



<a name="226710478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710478">(Feb 17 2021 at 19:17)</a>:</h4>
<p>i mean it's not "1" but it's fairly cheap</p>



<a name="226710676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710676">(Feb 17 2021 at 19:18)</a>:</h4>
<p>All of those blends are fairly expensive with SSE2.</p>



<a name="226710686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710686">(Feb 17 2021 at 19:18)</a>:</h4>
<p>Lovely, it seems someone has built a library that we can conveniently use for testing at least a few of our theories about performance.</p>



<a name="226710759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710759">(Feb 17 2021 at 19:19)</a>:</h4>
<p>It is one blend ;p</p>



<a name="226710821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710821">(Feb 17 2021 at 19:19)</a>:</h4>
<p>Oh I misread, I was looking at the lower part</p>



<a name="226710825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710825">(Feb 17 2021 at 19:19)</a>:</h4>
<p>and it comes out to like 4 bit ops</p>



<a name="226710853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710853">(Feb 17 2021 at 19:19)</a>:</h4>
<p>You are converting to integer and back?</p>



<a name="226710962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226710962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226710962">(Feb 17 2021 at 19:20)</a>:</h4>
<p>yes with that specific op it's specified to do the right thing</p>



<a name="226711299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226711299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226711299">(Feb 17 2021 at 19:22)</a>:</h4>
<p>Even nans?</p>



<a name="226711330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226711330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226711330">(Feb 17 2021 at 19:22)</a>:</h4>
<p>Also it definitely results in a pipeline stall</p>



<a name="226711596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226711596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226711596">(Feb 17 2021 at 19:24)</a>:</h4>
<p>well, yeah some stalling</p>



<a name="226711611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226711611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226711611">(Feb 17 2021 at 19:24)</a>:</h4>
<p>less though</p>



<a name="226711633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226711633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226711633">(Feb 17 2021 at 19:25)</a>:</h4>
<p>nan i forget</p>



<a name="226711666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226711666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226711666">(Feb 17 2021 at 19:25)</a>:</h4>
<p>there's probably tests in there that nan stays nan</p>



<a name="226711734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226711734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226711734">(Feb 17 2021 at 19:25)</a>:</h4>
<p>maybe</p>



<a name="226711818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226711818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226711818">(Feb 17 2021 at 19:26)</a>:</h4>
<p>i haven't worked on the lib actively in over a year since there wasn't much new to do with it</p>



<a name="226712172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226712172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226712172">(Feb 17 2021 at 19:28)</a>:</h4>
<p>Okay looks like they throw a fpe, so it needs to be masked off and handled separately, perhaps</p>



<a name="226712373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226712373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226712373">(Feb 17 2021 at 19:30)</a>:</h4>
<p>So the other issue I have with this is that AVX512 at least has merged add and round instructions that you lose access to</p>



<a name="226712521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226712521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226712521">(Feb 17 2021 at 19:31)</a>:</h4>
<p>Not just add, various arithmetic ops</p>



<a name="226712646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226712646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226712646">(Feb 17 2021 at 19:32)</a>:</h4>
<p>...Alright?</p>



<a name="226712900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226712900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226712900">(Feb 17 2021 at 19:34)</a>:</h4>
<p>will LLVM even emit those if you give it a sequenced add and round?</p>



<a name="226712953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226712953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226712953">(Feb 17 2021 at 19:34)</a>:</h4>
<p>I don't see why not, it already merges mask operations</p>



<a name="226713254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226713254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226713254">(Feb 17 2021 at 19:36)</a>:</h4>
<p>regardless, any software solutions we'd want would only be emitted for cases where we don't have higher-level target features.</p>



<a name="226713482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226713482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226713482">(Feb 17 2021 at 19:38)</a>:</h4>
<p>That's only if we use the intrinsic and fix it in LLVM, no?</p>



<a name="226714358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226714358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226714358">(Feb 17 2021 at 19:44)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> Okay, can you explain as much as you know about how compiler-builtins and rustlibm works?</p>



<a name="226714610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226714610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226714610">(Feb 17 2021 at 19:46)</a>:</h4>
<p>so compiler-builtins is built and linked as part of the core build process and it provides junk llvm expects you to have like memcpy and software division and whatever. it's deliberately conservative about what it offers so as to avoid clashing with other software you might link.</p>



<a name="226714627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226714627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226714627">(Feb 17 2021 at 19:46)</a>:</h4>
<p>How do compiler builtins work, basically? I am realizing I have an inadequate knowledge of it.</p>



<a name="226714635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226714635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226714635">(Feb 17 2021 at 19:46)</a>:</h4>
<p><em>nods</em></p>



<a name="226714675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226714675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226714675">(Feb 17 2021 at 19:47)</a>:</h4>
<p>on some targets (eg: wasm) portions of the rust libm crate are built and linked</p>



<a name="226714728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226714728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226714728">(Feb 17 2021 at 19:47)</a>:</h4>
<p>via git sub-module and direct inclusion of source files, not via building the whole crate and linking it "normally"</p>



<a name="226714848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226714848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226714848">(Feb 17 2021 at 19:48)</a>:</h4>
<p>it's "just a library", but it provides some weird stuff that often has names starting with two underscores</p>



<a name="226715027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715027">(Feb 17 2021 at 19:49)</a>:</h4>
<p>@ketsuban and i once had to submit a division routine because you could sometimes have that emitted on the gba and compiler-builtins didn't already have it (we were "luckily" some of the first people to be building rust for a CPU without an integer division instruction)</p>



<a name="226715105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715105">(Feb 17 2021 at 19:50)</a>:</h4>
<p>amazing</p>



<a name="226715175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715175">(Feb 17 2021 at 19:50)</a>:</h4>
<p>so basically it does... text expansion?</p>



<a name="226715210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715210">(Feb 17 2021 at 19:51)</a>:</h4>
<p>it's... more like a macro than building in MIR or ASM?</p>



<a name="226715221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715221">(Feb 17 2021 at 19:51)</a>:</h4>
<p>it's rust functions</p>



<a name="226715240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715240">(Feb 17 2021 at 19:51)</a>:</h4>
<p>hm</p>



<a name="226715249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715249">(Feb 17 2021 at 19:51)</a>:</h4>
<p>like, just rust code basically</p>



<a name="226715288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715288">(Feb 17 2021 at 19:51)</a>:</h4>
<p>and it exposes unmangled symbols llvm expects will exist sometimes</p>



<a name="226715392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715392">(Feb 17 2021 at 19:52)</a>:</h4>
<p>(which for the record is more or less how we would handle libmvec, I think)</p>



<a name="226715396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715396">(Feb 17 2021 at 19:52)</a>:</h4>
<p>the two things to keep in mind are:<br>
1) if you can show you really need it they're pretty cool with adding new stuff<br>
2) you gotta be careful about not exporting an unmangled symbol too often because of possible clashes</p>



<a name="226715473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715473">(Feb 17 2021 at 19:52)</a>:</h4>
<p>well, <em>accepting</em> new stuff. you do the PR they merge it, they don't just make code for you ;p</p>



<a name="226715523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715523">(Feb 17 2021 at 19:53)</a>:</h4>
<p>Okay, and <span class="user-mention" data-user-id="312331">@Caleb Zulawski</span>, does libmvec address problem 0 or? I am not sure what it actually gives us.</p>



<a name="226715524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715524">(Feb 17 2021 at 19:53)</a>:</h4>
<p>lunch over, I'll check back later</p>



<a name="226715674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715674">(Feb 17 2021 at 19:54)</a>:</h4>
<p>It gives us two things, if we write it in pure rust it gives us those functions in core. It also gives us improved performance in the base case</p>



<a name="226715753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715753">(Feb 17 2021 at 19:54)</a>:</h4>
<p>I do think we need to consider those problems separately. I personally think performance is the much more important issue and the float-in-core problem is broader than just stdsimd</p>



<a name="226715870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715870">(Feb 17 2021 at 19:55)</a>:</h4>
<p>(i was secretly hoping we wouldn't hit this and we could just backdoor floats into core <em>via</em> stdsimd)</p>



<a name="226715981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226715981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226715981">(Feb 17 2021 at 19:56)</a>:</h4>
<p>(also Problem 0 is a great indie game title if ever there was)</p>



<a name="226716084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716084">(Feb 17 2021 at 19:56)</a>:</h4>
<p>Also I just did a totally scientific survey of well known SIMD-using crates and all of the ones I saw (memchr, aho_corasick, ppv-lite86) used the target_feature attribute</p>



<a name="226716086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716086">(Feb 17 2021 at 19:56)</a>:</h4>
<p>Alright.<br>
I just want to understand everything as much as possible at the moment, we have... a few problems, and we have a few solutions, and different members of the set of solutions address different members of the set of problems, often only actually doing so in concert (i.e. as multiple members of a subset).</p>



<a name="226716289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716289">(Feb 17 2021 at 19:58)</a>:</h4>
<p>Okay, so, my understanding is that target_feature is a couple things.<br>
One is <code>#[target_feature(enable)]</code>.<br>
and one is <code>#[cfg(target_feature)]</code>.</p>



<a name="226716295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716295">(Feb 17 2021 at 19:58)</a>:</h4>
<p>So personally I would like to see an argument <em>against</em> using libmvec since that appears to be the direction llvm (and therefore clang) is going</p>



<a name="226716351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716351">(Feb 17 2021 at 19:58)</a>:</h4>
<p>here's one: we're not llvm! what about cranelift?</p>



<a name="226716360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716360">(Feb 17 2021 at 19:58)</a>:</h4>
<p>Sure I meant specifically the attribute, not the cfg value</p>



<a name="226716435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716435">(Feb 17 2021 at 19:59)</a>:</h4>
<p>Well frankly that's another reason to use libmvec imo, cranelift can call it as well and get the same performance</p>



<a name="226716473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716473">(Feb 17 2021 at 19:59)</a>:</h4>
<p>Well what we really want is to static link to libmvec, don't we?</p>



<a name="226716506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716506">(Feb 17 2021 at 20:00)</a>:</h4>
<p>Or are you including that.</p>



<a name="226716579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716579">(Feb 17 2021 at 20:00)</a>:</h4>
<p>Yes. Also to be clear I'm proposing writing our own libmvec, not using GNU</p>



<a name="226716605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716605">(Feb 17 2021 at 20:00)</a>:</h4>
<p>Okay.<br>
Yeah I figured.</p>



<a name="226716612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716612">(Feb 17 2021 at 20:00)</a>:</h4>
<p>It's literally like 5 functions</p>



<a name="226716627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716627">(Feb 17 2021 at 20:00)</a>:</h4>
<p>e-z p-z</p>



<a name="226716788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716788">(Feb 17 2021 at 20:02)</a>:</h4>
<p>Okay, so rustlibm grows up and includes rustlibmvec.</p>



<a name="226716854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716854">(Feb 17 2021 at 20:02)</a>:</h4>
<p>separate crate feel better</p>



<a name="226716863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716863">(Feb 17 2021 at 20:02)</a>:</h4>
<p>Yeah more or less. Though I think maybe it belongs in a separate crate</p>



<a name="226716865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716865">(Feb 17 2021 at 20:02)</a>:</h4>
<p>yeah probably.</p>



<a name="226716868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226716868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226716868">(Feb 17 2021 at 20:02)</a>:</h4>
<p>(deleted)</p>



<a name="226717057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717057">(Feb 17 2021 at 20:04)</a>:</h4>
<p>So this doesn't specifically fix round, but it fixes the transcendental functions</p>



<a name="226717111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717111">(Feb 17 2021 at 20:04)</a>:</h4>
<p>Only because that's currently what LLVM supports</p>



<a name="226717113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717113">(Feb 17 2021 at 20:04)</a>:</h4>
<p>amusing.</p>



<a name="226717231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717231">(Feb 17 2021 at 20:05)</a>:</h4>
<p>I believe Rust has maintained LLVM patches before.</p>



<a name="226717276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717276">(Feb 17 2021 at 20:05)</a>:</h4>
<p>I think this is something that could be upstreamed anyway</p>



<a name="226717308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717308">(Feb 17 2021 at 20:06)</a>:</h4>
<p>yes.<br>
I mostly mean I do not think it would be unreasonable to fix something now and upstream the patch.</p>



<a name="226717362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717362">(Feb 17 2021 at 20:06)</a>:</h4>
<p>so we do not have to wait an aeon.</p>



<a name="226717370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717370">(Feb 17 2021 at 20:06)</a>:</h4>
<p>rust patches llvm but only in ways that allow using unpatched llvm still</p>



<a name="226717392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717392">(Feb 17 2021 at 20:06)</a>:</h4>
<p>would this qualify?</p>



<a name="226717427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717427">(Feb 17 2021 at 20:06)</a>:</h4>
<p>technically yes</p>



<a name="226717437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717437">(Feb 17 2021 at 20:06)</a>:</h4>
<p>probably depends how we do it</p>



<a name="226717446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717446">(Feb 17 2021 at 20:06)</a>:</h4>
<p>Though I'm not actually positive libmvec provides rounding at all? If it does were good but but if it doesn't we may need to make our own vector lib (which I imagine would also be ok)</p>



<a name="226717522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717522">(Feb 17 2021 at 20:07)</a>:</h4>
<p>We could make LLVM aware that libmvec could offer <strong>six</strong> whole functions!</p>



<a name="226717530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717530">(Feb 17 2021 at 20:07)</a>:</h4>
<p>core simd relies on a core lib for simd that can't use core simd without causing compilation loops. success.</p>



<a name="226717580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717580">(Feb 17 2021 at 20:07)</a>:</h4>
<p>lol</p>



<a name="226717587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717587">(Feb 17 2021 at 20:08)</a>:</h4>
<p>ah right hm</p>



<a name="226717641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717641">(Feb 17 2021 at 20:08)</a>:</h4>
<p>that is tricky</p>



<a name="226717695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717695">(Feb 17 2021 at 20:08)</a>:</h4>
<p>ideally this would use core_simd so we could have the benefit of ensuring our API is good enough to implement something like this.</p>



<a name="226717701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717701">(Feb 17 2021 at 20:08)</a>:</h4>
<p>My silly-tier proposal: what if we were our own crate alongside core and alloc and std? or does that not make it go away.</p>



<a name="226717885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226717885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226717885">(Feb 17 2021 at 20:10)</a>:</h4>
<p>Because really, I don't care about landing in core as much as I want to be in <strong>rustc</strong>.</p>



<a name="226718148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226718148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226718148">(Feb 17 2021 at 20:12)</a>:</h4>
<p>I don't think anything makes this go away other than fixing codegen.</p>



<a name="226718201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226718201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226718201">(Feb 17 2021 at 20:12)</a>:</h4>
<p>I personally think this is absolutely something we can ignore before going into nightly and perhaps even stable</p>



<a name="226718418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226718418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226718418">(Feb 17 2021 at 20:14)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> what is the compilation loop you are envisioning exactly?</p>



<a name="226718655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226718655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226718655">(Feb 17 2021 at 20:15)</a>:</h4>
<p>well rust-lib-vec-m can't call f32x4::round in its round implementation</p>



<a name="226718858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226718858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226718858">(Feb 17 2021 at 20:17)</a>:</h4>
<p>I think you would just take musl libm's implementation and make it vectorized?</p>



<a name="226718882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226718882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226718882">(Feb 17 2021 at 20:17)</a>:</h4>
<p>yeah whatever we want to do there</p>



<a name="226718903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226718903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226718903">(Feb 17 2021 at 20:18)</a>:</h4>
<p>But yeah no intrinsic there</p>



<a name="226718947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226718947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226718947">(Feb 17 2021 at 20:18)</a>:</h4>
<p>we just can't have the code that comes out of an intrinsic call be itself an intrinsic call</p>



<a name="226719086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719086">(Feb 17 2021 at 20:19)</a>:</h4>
<p>if a call actually reaches lib vec m then we know that llvm already tried it's best; so we do whatever dumb obvious thing is required for the given op, base features only, etc etc</p>



<a name="226719273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719273">(Feb 17 2021 at 20:21)</a>:</h4>
<p>Agreed, it doesn't need to be great, just better than libm calls</p>



<a name="226719309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719309">(Feb 17 2021 at 20:21)</a>:</h4>
<p>So one question</p>



<a name="226719359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719359">(Feb 17 2021 at 20:21)</a>:</h4>
<p>Since gnu libmvec doesn't cover all of the functions we need, do we try to make our own vector lib and get it upstreamed into LLVM?</p>



<a name="226719541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719541">(Feb 17 2021 at 20:23)</a>:</h4>
<p>Another reason to do that is we can maintain the rust calling convention</p>



<a name="226719791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719791">(Feb 17 2021 at 20:25)</a>:</h4>
<p>rust calling convention isn't stable</p>



<a name="226719829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719829">(Feb 17 2021 at 20:25)</a>:</h4>
<p>we can teach llvm to use our lib, but it'd be the C abi</p>



<a name="226719936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719936">(Feb 17 2021 at 20:26)</a>:</h4>
<p>Yeah true.</p>



<a name="226719967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226719967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226719967">(Feb 17 2021 at 20:26)</a>:</h4>
<p>I'm not sure about the ABI implications of passing vectors</p>



<a name="226720008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720008">(Feb 17 2021 at 20:26)</a>:</h4>
<p>Especially on non-x86_64 platforms</p>



<a name="226720425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720425">(Feb 17 2021 at 20:29)</a>:</h4>
<p>System V AMD64 ABI we should be able to pass vectors in registers just fine.</p>



<a name="226720614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720614">(Feb 17 2021 at 20:30)</a>:</h4>
<p>and __vectorcall should support extensive register use on x64 as well.</p>



<a name="226720684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720684">(Feb 17 2021 at 20:31)</a>:</h4>
<p>I'm more concerned about arm, aarch64, ppc, etc mostly because I don't know much about the calling conventions</p>



<a name="226720697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720697">(Feb 17 2021 at 20:31)</a>:</h4>
<p>the way you pass larger vectors would depend on your target_feature level if we use the C abi</p>



<a name="226720749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720749">(Feb 17 2021 at 20:32)</a>:</h4>
<p>Yeah that's why I thought we may need to pass them by reference</p>



<a name="226720836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720836">(Feb 17 2021 at 20:32)</a>:</h4>
<p>Actually wait, the function were calling into is always the base feature level</p>



<a name="226720850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720850">(Feb 17 2021 at 20:32)</a>:</h4>
<p>we should be able to basically always pass using xmm registers on AMD64 though.</p>



<a name="226720858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720858">(Feb 17 2021 at 20:32)</a>:</h4>
<p>Unless the source function features matter</p>



<a name="226720928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720928">(Feb 17 2021 at 20:33)</a>:</h4>
<p>might have to load a ymm or zmm into multiple xmm regs</p>



<a name="226720956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720956">(Feb 17 2021 at 20:33)</a>:</h4>
<p>basic Windows ABI supports some xmm register usage</p>



<a name="226720960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720960">(Feb 17 2021 at 20:33)</a>:</h4>
<p>Remember you only have a few of them</p>



<a name="226720978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226720978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226720978">(Feb 17 2021 at 20:33)</a>:</h4>
<p>correct.</p>



<a name="226721037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721037">(Feb 17 2021 at 20:33)</a>:</h4>
<p>i mean passing a f32x8 will use ymm if you have <code>target_feature="+avx"</code>. Note that this is exactly this soundness hole: <a href="https://github.com/rust-lang/rust/issues/64609">https://github.com/rust-lang/rust/issues/64609</a></p>



<a name="226721084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721084">(Feb 17 2021 at 20:34)</a>:</h4>
<p>mmmhm.</p>



<a name="226721087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721087">(Feb 17 2021 at 20:34)</a>:</h4>
<p>hmm.</p>



<a name="226721141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721141">(Feb 17 2021 at 20:34)</a>:</h4>
<p>i think even passing 2 f32x4s will differ</p>



<a name="226721171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721171">(Feb 17 2021 at 20:34)</a>:</h4>
<p>i dont really remember though, its been a while</p>



<a name="226721215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721215">(Feb 17 2021 at 20:35)</a>:</h4>
<p>lib vec m would have to assume default feature level per target</p>



<a name="226721253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721253">(Feb 17 2021 at 20:35)</a>:</h4>
<p>so that at least lets us predict the calling convention</p>



<a name="226721284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721284">(Feb 17 2021 at 20:35)</a>:</h4>
<p>Yeah, I think it's not an issue since the features can't change</p>



<a name="226721290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721290">(Feb 17 2021 at 20:35)</a>:</h4>
<p>but that doesn't fix the caller's side necessarily</p>



<a name="226721293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721293">(Feb 17 2021 at 20:35)</a>:</h4>
<p>aarch64 (Armv8-A) is specified to always have Neon, and its ABI uses those Neon registers, last I checked.</p>



<a name="226721375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721375">(Feb 17 2021 at 20:36)</a>:</h4>
<p>soundness hole maybe still bites us</p>



<a name="226721499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721499">(Feb 17 2021 at 20:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226719967">said</a>:</p>
<blockquote>
<p>I'm not sure about the ABI implications of passing vectors</p>
</blockquote>
<p>The rust abi always passes vectors by-ref, unless you are on wasm.</p>



<a name="226721567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721567">(Feb 17 2021 at 20:37)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/bb587b1a1737738658d2eaecd4c8c1cab555257a/compiler/rustc_middle/src/ty/layout.rs#L2854-L2879">https://github.com/rust-lang/rust/blob/bb587b1a1737738658d2eaecd4c8c1cab555257a/compiler/rustc_middle/src/ty/layout.rs#L2854-L2879</a></p>



<a name="226721584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721584">(Feb 17 2021 at 20:37)</a>:</h4>
<p>that is awful.</p>



<a name="226721683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Darley Barreto <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721683">(Feb 17 2021 at 20:38)</a>:</h4>
<p>As a bystander I can refer <a href="https://github.com/xtensor-stack/xsimd/tree/master">xsimd</a> as another source of inspirations besides musl libm</p>



<a name="226721773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721773">(Feb 17 2021 at 20:39)</a>:</h4>
<p>I don't know if we can reference a BSD3 library.</p>



<a name="226721795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226721795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226721795">(Feb 17 2021 at 20:39)</a>:</h4>
<p>There's some MIT code in Agner's vectorcall2</p>



<a name="226722191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226722191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226722191">(Feb 17 2021 at 20:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226721141">said</a>:</p>
<blockquote>
<p>i think even passing 2 f32x4s will differ</p>
</blockquote>
<p>It won't because the start of each is SSE and not SSEUP. However, this does impact passing the larger vectors as mentioned.</p>
<p><span class="user-mention silent" data-user-id="372321">Darley Barreto</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226721683">said</a>:</p>
<blockquote>
<p>As a bystander I can refer <a href="https://github.com/xtensor-stack/xsimd/tree/master">xsimd</a> as another source of inspirations besides musl libm</p>
</blockquote>
<p>SLEEF also exists (BSL though, unsure if we can use it): <a href="https://sleef.org/">https://sleef.org/</a></p>



<a name="226722551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226722551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Darley Barreto <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226722551">(Feb 17 2021 at 20:45)</a>:</h4>
<p><a href="https://github.com/agenium-scale/nsimd">nsimd</a> is MIT's. But I've never heard about it before.</p>



<a name="226723120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226723120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226723120">(Feb 17 2021 at 20:49)</a>:</h4>
<p>not a lawyer, but the take from the debian repo folks is that if you translate C to Rust you've made a derivative work but that's not the original source code any more, so unless there's license restrictions on derivative works then it's all cool.</p>
<p>source: there's an open issue about it in the libm repo actually.</p>



<a name="226723394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226723394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Darley Barreto <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226723394">(Feb 17 2021 at 20:51)</a>:</h4>
<p>Just one more: <a href="https://github.com/aff3ct/MIPP/tree/master">MIPP</a>, also MIT's</p>



<a name="226725157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226725157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226725157">(Feb 17 2021 at 21:03)</a>:</h4>
<blockquote>
<p>so unless there's license restrictions on derivative works</p>
</blockquote>
<p>By default derivative works will inherit the copyright (and thus the license) of the thing they derive from unless it's explicitly granted.</p>



<a name="226725206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226725206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226725206">(Feb 17 2021 at 21:03)</a>:</h4>
<p>not a lawyer, but that's my understanding</p>



<a name="226725844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226725844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226725844">(Feb 17 2021 at 21:08)</a>:</h4>
<p>soorta.</p>



<a name="226725902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226725902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226725902">(Feb 17 2021 at 21:08)</a>:</h4>
<p><a href="https://github.com/rust-lang/libm/issues/215">https://github.com/rust-lang/libm/issues/215</a> I'm going by what i read here</p>



<a name="226726122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226726122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226726122">(Feb 17 2021 at 21:10)</a>:</h4>
<p>notably:<br>
<a href="https://alioth-lists.debian.net/pipermail/pkg-rust-maintainers/2020-February/009954.html">https://alioth-lists.debian.net/pipermail/pkg-rust-maintainers/2020-February/009954.html</a></p>
<p><a href="https://github.com/rust-lang/compiler-builtins/issues/307#issuecomment-592007706">https://github.com/rust-lang/compiler-builtins/issues/307#issuecomment-592007706</a></p>



<a name="226726821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226726821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226726821">(Feb 17 2021 at 21:15)</a>:</h4>
<p>Even GPL has a lot of untested legal aspects</p>



<a name="226726873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226726873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226726873">(Feb 17 2021 at 21:15)</a>:</h4>
<p>It's still extremely unclear if you can static link against GPL from non GPL and distribute it</p>



<a name="226726919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226726919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226726919">(Feb 17 2021 at 21:16)</a>:</h4>
<p>I agree that anything derivative from MIT is fine</p>



<a name="226727893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226727893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226727893">(Feb 17 2021 at 21:23)</a>:</h4>
<p>we need the rust foundation to pay a lawyer to tell us the truth (you can't handle the truth)</p>



<a name="226728390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226728390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226728390">(Feb 17 2021 at 21:27)</a>:</h4>
<p>toy vector truncf implementation I just wrote: <a href="https://gcc.godbolt.org/z/d9Gz49">https://gcc.godbolt.org/z/d9Gz49</a></p>



<a name="226731813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226731813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Darley Barreto <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226731813">(Feb 17 2021 at 21:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226727893">said</a>:</p>
<blockquote>
<p>we need the rust foundation to pay a lawyer to tell us the truth (you can't handle the truth)</p>
</blockquote>
<p>meanwhile <a href="https://tldrlegal.com/">tldrlegal</a></p>



<a name="226734956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226734956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226734956">(Feb 17 2021 at 22:10)</a>:</h4>
<p>i think this issue is unfortunately more nuanced than tldr can deal with.</p>



<a name="226735331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226735331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226735331">(Feb 17 2021 at 22:11)</a>:</h4>
<p><a href="https://rosenlaw.com/oslbook.htm">https://rosenlaw.com/oslbook.htm</a></p>



<a name="226735861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226735861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226735861">(Feb 17 2021 at 22:14)</a>:</h4>
<p>Okay ,so if I understand correctly, the rustcall ABI does not use xmm registers to pass vectors, correct?</p>



<a name="226736247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226736247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226736247">(Feb 17 2021 at 22:15)</a>:</h4>
<p>even on x86_64?</p>



<a name="226736265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226736265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226736265">(Feb 17 2021 at 22:15)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> you've linked that before... does it actually cover the question here?</p>



<a name="226737194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226737194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226737194">(Feb 17 2021 at 22:22)</a>:</h4>
<p>It talks quite a bit about what creates a derivative work, about how the FSF's definition of linking creating derivative works is untested, requirements for use of reciprocal/academic licenses, etc.  Not at all a TLDR -- it's a full O'Reily book -- but definitely relevant for someone trying to get an understanding of the issues.</p>



<a name="226737347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226737347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226737347">(Feb 17 2021 at 22:24)</a>:</h4>
<p>we just need one question answered by a lawyer speaking lawyerly ;_; not another non-lawyer (eg: me) reading stuff and making a  non-lawyer judgement call</p>



<a name="226737493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226737493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226737493">(Feb 17 2021 at 22:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/226735861">said</a>:</p>
<blockquote>
<p>Okay ,so if I understand correctly, the rustcall ABI does not use xmm registers to pass vectors, correct?</p>
</blockquote>
<p>this seems like a bug we'd eventually want to fix, so i think we should probably not rely on this being the case forever</p>



<a name="226737688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226737688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226737688">(Feb 17 2021 at 22:27)</a>:</h4>
<p>but yes afaict this is true.</p>



<a name="226737852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226737852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226737852">(Feb 17 2021 at 22:28)</a>:</h4>
<p>The only way to fix it is to give target feature functions their own abi, I think</p>



<a name="226738121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226738121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226738121">(Feb 17 2021 at 22:31)</a>:</h4>
<p>hm, yeah, i see</p>



<a name="226738802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226738802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226738802">(Feb 17 2021 at 22:36)</a>:</h4>
<p>which brings us back to the <em>soundness hole</em></p>



<a name="226740815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226740815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226740815">(Feb 17 2021 at 22:57)</a>:</h4>
<p>OK but do they need them for things compiled to x86_64-unknown-linux-gnu w/o target features?</p>



<a name="226740921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226740921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226740921">(Feb 17 2021 at 22:58)</a>:</h4>
<p>I'm just picking on SysV64 because MS has their own ABI and vectorcall ABI.</p>



<a name="226747285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747285">(Feb 18 2021 at 00:04)</a>:</h4>
<p>Alright, so, "target_feature(enable)" allows unconditional code generation, but the functions must be unsafe unless called from a function that itself has the "target_feature(enable)" annotation.</p>
<p>And we have cfg on target features as well.<br>
...Is there a reason we can't implicitly annotate functions compiled with <code>-Ctarget-feature="sse2"</code> with <code>#[target_feature(enable="sse2")]</code></p>



<a name="226747398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747398">(Feb 18 2021 at 00:05)</a>:</h4>
<p>Actually right now they're always unsafe, until target-features 1.1 lands, at which point it will be how you describe</p>



<a name="226747479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747479">(Feb 18 2021 at 00:06)</a>:</h4>
<p>Oh OK.</p>



<a name="226747487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747487">(Feb 18 2021 at 00:06)</a>:</h4>
<p>Right, OK, not implemented. JOY.</p>



<a name="226747513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747513">(Feb 18 2021 at 00:06)</a>:</h4>
<p>It is actually implemented! Just not stable yet</p>



<a name="226747522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747522">(Feb 18 2021 at 00:06)</a>:</h4>
<p>ah</p>



<a name="226747538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747538">(Feb 18 2021 at 00:06)</a>:</h4>
<p>Okay well stabilizing it doesn't matter atm tbh.</p>



<a name="226747549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747549">(Feb 18 2021 at 00:06)</a>:</h4>
<p>We're on nightly.</p>



<a name="226747592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747592">(Feb 18 2021 at 00:07)</a>:</h4>
<p>So the functions kind of do implicitly gain the global target features</p>



<a name="226747598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747598">(Feb 18 2021 at 00:07)</a>:</h4>
<p>It just doesn't get you anything</p>



<a name="226747755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226747755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226747755">(Feb 18 2021 at 00:09)</a>:</h4>
<p>Well the <code>unsafe</code> part is fine.</p>



<a name="226768764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226768764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226768764">(Feb 18 2021 at 06:00)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> if a given target feature level is enabled at the build level (eg: <code>-Ctarget-feature="+avx"</code>) it is <em>as if</em> every function you're building suddenly had <code>#[target_feature(enable="avx")]</code> applied to it.</p>



<a name="226768792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226768792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226768792">(Feb 18 2021 at 06:01)</a>:</h4>
<p>target feature enable turns on a target feature that wouldn't have been in the function's feature set based on the global build settings</p>



<a name="226768803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226768803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226768803">(Feb 18 2021 at 06:01)</a>:</h4>
<p>but if the whole build has a given feature on, then they already all have that feature</p>



<a name="226768873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226768873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226768873">(Feb 18 2021 at 06:02)</a>:</h4>
<p>except of course the standard library which is pre-compiled at a given feature set (and feature set mismatches can cause the <del>soundness hole</del> bonus behavior)</p>



<a name="226774520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226774520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226774520">(Feb 18 2021 at 07:42)</a>:</h4>
<p>hmm.</p>



<a name="226904525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226904525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226904525">(Feb 19 2021 at 00:25)</a>:</h4>
<p>Well, I just followed that rabbithole and enumerated the combination of hardware and software quirks as they apply to the System V AMD64 ABI for about 1200 words, as a prelude to mocking up a design for attacking the soundness problem.</p>



<a name="226915409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226915409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226915409">(Feb 19 2021 at 03:13)</a>:</h4>
<p>1200 words is a pleasant walk in the park of an essay.</p>



<a name="226937996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/226937996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#226937996">(Feb 19 2021 at 09:19)</a>:</h4>
<p>The greatly abbreviated version of it became this comment. <a href="https://github.com/rust-lang/rust/issues/64609#issuecomment-781833026">https://github.com/rust-lang/rust/issues/64609#issuecomment-781833026</a><br>
I believe I need to expand on it further though in order to like... assemble an MCP or RFC, whichever.</p>



<a name="227009006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227009006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227009006">(Feb 19 2021 at 18:48)</a>:</h4>
<p>Are ABI decisions a T-compiler or T-lang issue?</p>



<a name="227010271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227010271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227010271">(Feb 19 2021 at 18:56)</a>:</h4>
<p>lang</p>



<a name="227010323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227010323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227010323">(Feb 19 2021 at 18:57)</a>:</h4>
<p>well, lang first, then compiler implements it once it's ratified</p>



<a name="227010406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227010406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227010406">(Feb 19 2021 at 18:57)</a>:</h4>
<p>basically, if an alternate rust compiler would also need to abide by something to still be a rust compiler, it's lang</p>



<a name="227010564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227010564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227010564">(Feb 19 2021 at 18:58)</a>:</h4>
<p>Hmm, does it matter if the rustcall ABI is still perma-unstable?</p>



<a name="227010616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227010616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227010616">(Feb 19 2021 at 18:58)</a>:</h4>
<p>or does it "matter" because it would permanently tilt the rustcall ABI towards a given set of possibilities.</p>



<a name="227010971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227010971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227010971">(Feb 19 2021 at 19:01)</a>:</h4>
<p>second one</p>



<a name="227011055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227011055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227011055">(Feb 19 2021 at 19:01)</a>:</h4>
<p>Fair enough.</p>



<a name="227011990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227011990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227011990">(Feb 19 2021 at 19:07)</a>:</h4>
<p>we can just ping <span class="user-mention" data-user-id="239881">@Josh Triplett</span> , who would  effectively be our lang team liason for this project. i mean technically this is a libs project, yada yada, but based on their interest areas if you had to pick a lang member for liason, you'd pick joshT for this one.</p>



<a name="227013023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227013023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227013023">(Feb 19 2021 at 19:14)</a>:</h4>
<p>So as much as that's a bug I want to be fixed, why exactly is this relevant to stdsimd?  Passing by reference, as unfortunate as it is, fixes the soundness hole afaik.  And for libmvec we don't have this problem since it's not the rust call ABI anyway</p>



<a name="227013321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227013321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227013321">(Feb 19 2021 at 19:16)</a>:</h4>
<p>best as i can tell, like the libm problem itself, this isn't required to proceed with building programs <em>at all</em>, it's required to proceed with building programs <em>that perform well</em></p>



<a name="227013402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227013402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227013402">(Feb 19 2021 at 19:16)</a>:</h4>
<p>So, on one hand<br>
Maybe it's not.<br>
On the other, the future of how this is handled directly impacts us.<br>
And the easiest way to predict that future is simply to make it.</p>



<a name="227013538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227013538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227013538">(Feb 19 2021 at 19:17)</a>:</h4>
<p>Sure. I just want to make sure we're all on the same page that it's probably not necessary</p>



<a name="227013714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227013714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227013714">(Feb 19 2021 at 19:18)</a>:</h4>
<p>In my experience most SIMD functions end up inlined anyway so I haven't personally hit this problem in rust (though I was aware of it)</p>



<a name="227013736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227013736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227013736">(Feb 19 2021 at 19:18)</a>:</h4>
<p>Basically, our library has to make less guesses about what is forward compatible with possible Rust code and Rust compilers if we just start describing what we are being compatible with.</p>



<a name="227014353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227014353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227014353">(Feb 19 2021 at 19:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227010564">said</a>:</p>
<blockquote>
<p>Hmm, does it matter if the rustcall ABI is still perma-unstable?</p>
</blockquote>
<p>If something is explicitly perma-unstable, like the <code>rustc_whatever</code> attributes, then it's a compiler decision, not a lang one.  Lang doesn't need cook-in-the-kitchen implementation choices, only things that affect exposed surface area.</p>



<a name="227014610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227014610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227014610">(Feb 19 2021 at 19:24)</a>:</h4>
<p>Hmm. Is <code>extern "Rust"</code> explicitly perma-unstable, or is it considered exposed surface API?</p>



<a name="227014780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227014780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227014780">(Feb 19 2021 at 19:25)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> there's always a limit to how much you can inline, so at some point this will hit you because you have to have a real function call eventually</p>



<a name="227014907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227014907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227014907">(Feb 19 2021 at 19:26)</a>:</h4>
<p>I don't think it's permanently unstable so much as there is very little desire to stabilize it and a bunch of arguments not to do it _yet_</p>



<a name="227015051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227015051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227015051">(Feb 19 2021 at 19:27)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> sure but usually you aren't passing vectors at that point. Not to say no one ever passes vectors, I'm just not sure it's the most critical problem to address.</p>



<a name="227015110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227015110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227015110">(Feb 19 2021 at 19:27)</a>:</h4>
<p>Not to say we can't or shouldn't but maybe not as the direction of the project group itself</p>



<a name="227015661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227015661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227015661">(Feb 19 2021 at 19:30)</a>:</h4>
<p>I am not going to block forward progress on this, obviously, I am keenly aware of our limited scope, we just also, as it happens, have a lot of the people relevant for discussing solutions to this problem in this "room" anyways. We wound up discussing <em>patches to LLVM</em>, after all, which is pretty far afield of our nominal mission.</p>



<a name="227015951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227015951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227015951">(Feb 19 2021 at 19:32)</a>:</h4>
<p>For what it's worth, if it was up to just me I probably wouldn't address the libm problem either <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> at least not yet</p>



<a name="227016027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227016027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227016027">(Feb 19 2021 at 19:32)</a>:</h4>
<p>But yeah, as long as we don't block any progress on anything because of it, that's all I wanted to make sure of</p>



<a name="227016044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227016044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227016044">(Feb 19 2021 at 19:33)</a>:</h4>
<p>nope, totally bullying you into writing C++ (no)</p>



<a name="227016201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227016201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227016201">(Feb 19 2021 at 19:33)</a>:</h4>
<p>caleb has to rewrite all of llvm in rust before we can land this in Nightly</p>



<a name="227016319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227016319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227016319">(Feb 19 2021 at 19:34)</a>:</h4>
<p>Fwiw if we need to PR LLVM into supporting a rust math vec lib I don't really mind lol</p>



<a name="227016394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227016394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227016394">(Feb 19 2021 at 19:34)</a>:</h4>
<p>CARCINIZE THE DRAGON!</p>



<a name="227016406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227016406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227016406">(Feb 19 2021 at 19:34)</a>:</h4>
<p>Honestly rather do that than deal with some gnu interface</p>



<a name="227016425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227016425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227016425">(Feb 19 2021 at 19:34)</a>:</h4>
<p><span aria-label="dragon" class="emoji emoji-1f409" role="img" title="dragon">:dragon:</span> <span aria-label="crab" class="emoji emoji-1f980" role="img" title="crab">:crab:</span></p>



<a name="227017127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017127">(Feb 19 2021 at 19:39)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> I would highly recommend treating anything Rosen says with many grains of salt; he has an agenda to push.</p>



<a name="227017189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017189">(Feb 19 2021 at 19:39)</a>:</h4>
<p>I just read through and caught up on something like 700 messages in this thread.</p>



<a name="227017217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017217">(Feb 19 2021 at 19:39)</a>:</h4>
<p>A few initial thoughts:</p>



<a name="227017290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017290">(Feb 19 2021 at 19:40)</a>:</h4>
<p>Oh hi! Sorry about that lol, we uh... do not do small discussions over here, obviously.</p>



<a name="227017322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017322">(Feb 19 2021 at 19:40)</a>:</h4>
<p>Not a problem. :)</p>



<a name="227017490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017490">(Feb 19 2021 at 19:41)</a>:</h4>
<p>Would it make sense to arrange to ship whole compiled versions of core/std for multiple target features? We don't have to do multiversioning quite yet (though we should), we could more easily just ship half a dozen versions of std and pick one to link to based on target features.</p>



<a name="227017650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017650">(Feb 19 2021 at 19:42)</a>:</h4>
<p>Bonus if we could pick a different one's MIR for inlining into a specific function based on target features.</p>



<a name="227017753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017753">(Feb 19 2021 at 19:43)</a>:</h4>
<p>All that said, function multiversioning probably isn't that hard to implement in rustc. But this could be a simpler stopgap.</p>



<a name="227017941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227017941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227017941">(Feb 19 2021 at 19:44)</a>:</h4>
<p>Regarding licensing, in general if you copy from a work you need to preserve the license and copyright notices of that work. But all permissive licenses are pretty much compatible with each other. Copying from 3-clause BSD or MIT or various others is fine, as long as you attribute it properly.</p>



<a name="227018025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018025">(Feb 19 2021 at 19:45)</a>:</h4>
<p>The amount of features can get pretty combinatoric there with x86. I wouldn't sneeze at it if you meant aarch64 or something, but</p>



<a name="227018049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018049">(Feb 19 2021 at 19:45)</a>:</h4>
<p>I personally think that the libm problem is purely a codegen issue and needs to be fixed in LLVM (which is where the libmvec solution comes from). Though I would like multiversioning eventually, I don't think it necessarily solves this particular problem</p>



<a name="227018146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018146">(Feb 19 2021 at 19:46)</a>:</h4>
<p>It can, but have you seen the x86 architecture levels proposal, which glibc, gcc, and LLVM are all cooperating on?</p>



<a name="227018171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018171">(Feb 19 2021 at 19:46)</a>:</h4>
<p>I have glanced at it!</p>



<a name="227018183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018183">(Feb 19 2021 at 19:46)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> We could have a version compiled for V2, V3, and V4.</p>



<a name="227018226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018226">(Feb 19 2021 at 19:47)</a>:</h4>
<p>That would give us a substantial fraction of the available performance on the table.</p>



<a name="227018264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018264">(Feb 19 2021 at 19:47)</a>:</h4>
<p>Sounds plausible, and would improve directing our users, since it would be "just smack this and don't worry about it".</p>



<a name="227018307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018307">(Feb 19 2021 at 19:47)</a>:</h4>
<p>I do think that would be useful, but my real concern is that every software I have personally needed to write needs to run everywhere (so either v1 or v2)</p>



<a name="227018319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018319">(Feb 19 2021 at 19:47)</a>:</h4>
<p>instead of "so, about SSE3, SSSE3, and SSE4.1, SSE4.2, and SSE4a..."</p>



<a name="227018434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018434">(Feb 19 2021 at 19:48)</a>:</h4>
<p>And I still don't want to preclude using AVX+ for things that fallback to libm</p>



<a name="227018438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018438">(Feb 19 2021 at 19:48)</a>:</h4>
<p>At the cost of shipping four copies of std, which really doesn't seem like an excessive cost. On the off chance people deeply cared about the additional size of three more copies of std in the rust tool chain, we could add an additional rustup component for the simd versions. but I would rather not, if we could get away with just shipping four copies.</p>



<a name="227018710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018710">(Feb 19 2021 at 19:50)</a>:</h4>
<p>I wonder how much extra weight it actually looks like</p>



<a name="227018722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018722">(Feb 19 2021 at 19:50)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> if you have to run everywhere, then you probably want runtime detection and function multiversioning.</p>



<a name="227018907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018907">(Feb 19 2021 at 19:52)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> If we do it in the most obvious way, it looks like four copies of std. If we narrow it to the subset that benefits most from optimization, we could decrease the weight, but at that point we're reinventing function multiversioning by another name and mechanism.</p>



<a name="227018981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227018981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227018981">(Feb 19 2021 at 19:52)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span>  could we dedupe functions that literally compile to exactly the same at different levels at least?</p>



<a name="227019213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019213">(Feb 19 2021 at 19:54)</a>:</h4>
<p>std is currently 23.7 MB, so ballpark of +75MB.</p>



<a name="227019239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019239">(Feb 19 2021 at 19:54)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span>  That's what I'm referring to.  This conversation came up because certain functions (such as round, sin, exp) fall back to libm for vectors at the base feature level.  We have been discussing writing pure rust implementations of those functions, but I personally am opposed to that since it precludes codegen from generating more efficient implementations when using multiversioning</p>



<a name="227019530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019530">(Feb 19 2021 at 19:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227018981">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span>  could we dedupe functions that literally compile to exactly the same at different levels at least?</p>
</blockquote>
<p>They'd also have to not want to call functions that differ by optimization level. But even if they're the same all the way down, it'd be tricky. Factoring those symbols out into a common library would be feasible, but again at that point you're reinventing multiversioning.</p>



<a name="227019574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019574">(Feb 19 2021 at 19:57)</a>:</h4>
<p>Even if we build rust std for various feature levels that allow more efficient implementations of those functions compiled into std, that would only work if you aren't multiversioning</p>



<a name="227019575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019575">(Feb 19 2021 at 19:57)</a>:</h4>
<p>licensing: this wouldn't be a copy this would be a translation, if that matters. and for example in the case of rust's libm crate this is no idle question. and whatever the answer is there, that's probably the same a answer for us here with vec libm</p>



<a name="227019636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019636">(Feb 19 2021 at 19:57)</a>:</h4>
<p>fair enough.</p>



<a name="227019729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019729">(Feb 19 2021 at 19:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227019574">said</a>:</p>
<blockquote>
<p>Even if we build rust std for various feature levels that allow more efficient implementations of those functions compiled into std, that would only work if you aren't multiversioning</p>
</blockquote>
<p>That wouldn't preclude multiversioning. We could, theoretically, do things like "if you're in a function that has x86_64-v3 as its target feature set, you can inline functions from the x86_64-v3 std".</p>



<a name="227019753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019753">(Feb 19 2021 at 19:58)</a>:</h4>
<p>That would take some work, but it would be easier than multiversioning.</p>



<a name="227019821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019821">(Feb 19 2021 at 19:59)</a>:</h4>
<p>You mean use a mixture of std implementations? That would be interesting and would potentially help. But I still think the most direct solution is to make codegen better</p>



<a name="227019905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019905">(Feb 19 2021 at 20:00)</a>:</h4>
<p>none of the fixes have to be done fully in place of also making llvm better</p>



<a name="227019933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227019933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227019933">(Feb 19 2021 at 20:00)</a>:</h4>
<p>Also, it's worth pointing something out about multiversioning that would make the above approach <em>better</em> in some cases: multiversioning primarily works when you're calling exported symbols from a library, or similar. You have to be calling something that's actually interposed by the GOT. If you're making more efficient calls within a library that bypass the GOT, you don't get multiversioning unless you invent it yourself.</p>



<a name="227020000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020000">(Feb 19 2021 at 20:00)</a>:</h4>
<p>If we can do things like inlining decisions based on target features, that would give us something <em>better</em> than existing implementations of multiversioning.</p>



<a name="227020003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020003">(Feb 19 2021 at 20:00)</a>:</h4>
<p>GOT =&gt; Global... Object Table?</p>



<a name="227020015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020015">(Feb 19 2021 at 20:00)</a>:</h4>
<p>Global Offset Table.</p>



<a name="227020205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020205">(Feb 19 2021 at 20:02)</a>:</h4>
<p>I suppose all I am saying is we should try to decouple the problems.  Having multiple stds would be great, multiversioning would be great, but using those to bypass an LLVM codegen issue is still a hack in my opinion</p>



<a name="227020254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020254">(Feb 19 2021 at 20:02)</a>:</h4>
<p>Whenever you call a function from a shared library, it jumps to a location that jumps again to the target location. The first time you do so (or eagerly if you use <code>LD_BIND_NOW</code> or the compile-time equivalent) it resolves the function (including any multiversioning) and then overwrites its own GOT entry to make it faster the next time.</p>



<a name="227020273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020273">(Feb 19 2021 at 20:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227020205">said</a>:</p>
<blockquote>
<p>I suppose all I am saying is we should try to decouple the problems.  Having multiple stds would be great, multiversioning would be great, but using those to bypass an LLVM codegen issue is still a hack in my opinion</p>
</blockquote>
<p>I'm not disagreeing with that in any way.</p>



<a name="227020357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020357">(Feb 19 2021 at 20:03)</a>:</h4>
<p>We should make LLVM better, and/or do better ourselves if we need to bypass LLVM to do so. And if we need to do both to cover different cases, so be it.</p>



<a name="227020401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020401">(Feb 19 2021 at 20:03)</a>:</h4>
<p>If one of those can cover everything and we don't have to do the other, great, but we might need more than one solution for full coverage of the problem space.</p>



<a name="227020532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020532">(Feb 19 2021 at 20:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227019575">said</a>:</p>
<blockquote>
<p>licensing: this wouldn't be a copy this would be a translation, if that matters. and for example in the case of rust's libm crate this is no idle question. and whatever the answer is there, that's probably the same a answer for us here with vec libm</p>
</blockquote>
<p>Copy vs translation doesn't matter here; either way it's a derivative work.</p>



<a name="227020537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020537">(Feb 19 2021 at 20:04)</a>:</h4>
<p>I agree with Josh, and alluded to that earlier: this may look like "one problem" but it's actually multiple smaller problems composed of multiple smaller problems each of which requires probably multiple solutions in concert to address.</p>



<a name="227020645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020645">(Feb 19 2021 at 20:05)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> then the rust standard library is in a wee bit of a pickle, but I'll PM you or start another thread or something later when I've got more time</p>



<a name="227020681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020681">(Feb 19 2021 at 20:05)</a>:</h4>
<p>welp lol</p>



<a name="227020731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020731">(Feb 19 2021 at 20:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227020645">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> then the rust standard library is in a wee bit of a pickle, but I'll PM you or start another thread or something later when I've got more time</p>
</blockquote>
<p>I'm aware that the licensing metadata hasn't been tracked as well as it should have been, if that's what you mean.</p>



<a name="227020749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020749">(Feb 19 2021 at 20:06)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> so what I'm hearing from you is that we need to make all problems into a crab?</p>



<a name="227020759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020759">(Feb 19 2021 at 20:06)</a>:</h4>
<p>tbh I think all projects are in a wee bit of a pickle regarding that. :^)</p>



<a name="227020764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020764">(Feb 19 2021 at 20:06)</a>:</h4>
<p>YES.</p>



<a name="227020777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020777">(Feb 19 2021 at 20:06)</a>:</h4>
<p>carcinize all the things</p>



<a name="227020784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020784">(Feb 19 2021 at 20:06)</a>:</h4>
<p>THE CRAB CYCLE, THERE IS ONLY ONE PROBLEM AND ONE SOLUTION, AND IT IS CRAB</p>



<a name="227020886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020886">(Feb 19 2021 at 20:07)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> I believe Rust doesn't use a PLT due to the relro level being partial by default.</p>



<a name="227020890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227020890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227020890">(Feb 19 2021 at 20:07)</a>:</h4>
<p>they were having trouble with rustdoc earlier and i asked if they should rewrite it in rust but somehow they didn't think that would help. shocking.</p>



<a name="227021023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021023">(Feb 19 2021 at 20:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227020886">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> I believe Rust doesn't use a PLT due to the relro level being partial by default.</p>
</blockquote>
<p>Which means that we can't do multiversioning in quite the same way that C/GCC/etc does it.</p>



<a name="227021168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021168">(Feb 19 2021 at 20:09)</a>:</h4>
<p>You can always implement it the same way but do an indirect function call from an atomic pointer instead</p>



<a name="227021248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021248">(Feb 19 2021 at 20:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227021168">said</a>:</p>
<blockquote>
<p>You can always implement it the same way but do an indirect function call from an atomic pointer instead</p>
</blockquote>
<p>Indirect function calls are expensive these days.</p>



<a name="227021266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021266">(Feb 19 2021 at 20:10)</a>:</h4>
<p>Security mitigations.</p>



<a name="227021293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021293">(Feb 19 2021 at 20:10)</a>:</h4>
<p>That's fair</p>



<a name="227021355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021355">(Feb 19 2021 at 20:11)</a>:</h4>
<p>Not sure it's necessarily any different than a vtable though?</p>



<a name="227021401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021401">(Feb 19 2021 at 20:11)</a>:</h4>
<p>It's actually cheaper to do <code>match some_global_constant { THING1 =&gt; func1(a, b, c), THING2 =&gt; func2(a, b, c), ... }</code> and let branch prediction know which one to use.</p>



<a name="227021527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021527">(Feb 19 2021 at 20:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227021355">said</a>:</p>
<blockquote>
<p>Not sure it's necessarily any different than a vtable though?</p>
</blockquote>
<p>Right, and vtables have similar problems. Hence the devirtualization optimization: if you have a pretty good idea of which variant you'll actually have, optimize for that case by saying "if it's this, call this, otherwise fall back to the indirect pointer".</p>



<a name="227021546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021546">(Feb 19 2021 at 20:12)</a>:</h4>
<p>So in my <code>multiversion</code> crate I use static atomic pointers for normal functions and branch prediction for generics (since there's no way to make generic statics) and yeah, I've found virtually no performance difference between the two</p>



<a name="227021601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021601">(Feb 19 2021 at 20:13)</a>:</h4>
<p>Though I also wouldn't say I've found branch prediction to be noticeably faster either</p>



<a name="227021610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021610">(Feb 19 2021 at 20:13)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> Is that with full security flags turned on, such as retpolines and similar?</p>



<a name="227021671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021671">(Feb 19 2021 at 20:13)</a>:</h4>
<p>Nope, I was just going to say I've only tested it in my own little world, so if you're convinced branch prediction is faster I may switch it!</p>



<a name="227021769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021769">(Feb 19 2021 at 20:14)</a>:</h4>
<p>Considering it also removes a bit of unsafe I'd consider that win-win</p>



<a name="227021781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021781">(Feb 19 2021 at 20:14)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> I'm convinced that the answer is "it's complicated, try benchmarking with security mitigations turned on and see".</p>



<a name="227021851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021851">(Feb 19 2021 at 20:14)</a>:</h4>
<p>how does one do that with rust?</p>



<a name="227021853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227021853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227021853">(Feb 19 2021 at 20:14)</a>:</h4>
<p>(Also worth noting, this is a transient state of affairs, and I'd expect the performance loss of mitigations to reduce over time. But in any case, branch prediction of branches that always go the same way is incredibly good, and basically free.)</p>



<a name="227022078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022078">(Feb 19 2021 at 20:16)</a>:</h4>
<p>My only hesitation was that maybe there is still some hardware out there with bad branch predictors</p>



<a name="227022126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022126">(Feb 19 2021 at 20:17)</a>:</h4>
<p>Or maybe microcontrollers with none</p>



<a name="227022170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022170">(Feb 19 2021 at 20:17)</a>:</h4>
<p>Though it's one of the simplest optimizations in a cpu, I think</p>



<a name="227022270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022270">(Feb 19 2021 at 20:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227021851">said</a>:</p>
<blockquote>
<p>how does one do that with rust?</p>
</blockquote>
<p>You'd turn on the appropriate compiler code-generation flags, which I'd have to dig up. Off the top of my head, <code>-C target-feature=retpoline</code> and several other related options; see <code>rustc --print target-features</code> and look up the set of things you would want to use in C to figure out the corresponding options. You don't want SESES though, it's a massive hammer that's an absurd performance hit. But most of the rest are used in much production code these days.</p>



<a name="227022303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022303">(Feb 19 2021 at 20:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227022078">said</a>:</p>
<blockquote>
<p>My only hesitation was that maybe there is still some hardware out there with bad branch predictors</p>
</blockquote>
<p>I think such hardware is going to be very sad performance-wise regardless, and this won't make it much sadder. ;)</p>



<a name="227022330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022330">(Feb 19 2021 at 20:18)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> it's not a simd question exactly but does all that apply to dynamically <em>loaded</em> libraries as well? eg: grabbing out a pile of vulkan functions form vulkan-1.dll or similar?</p>



<a name="227022414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022414">(Feb 19 2021 at 20:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227022078">said</a>:</p>
<blockquote>
<p>My only hesitation was that maybe there is still some hardware out there with bad branch predictors</p>
</blockquote>
<p>It's worth noting that "bad" is relative. x86 has ridiculously good branch prediction. It'd take many many years to get branch prediction that good. But you can get some decent improvements with well-known techniques.</p>



<a name="227022498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022498">(Feb 19 2021 at 20:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227022330">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> it's not a simd question exactly but does all that apply to dynamically <em>loaded</em> libraries as well? eg: grabbing out a pile of vulkan functions form vulkan-1.dll or similar?</p>
</blockquote>
<p>You mean with respect to licensing?</p>



<a name="227022523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022523">(Feb 19 2021 at 20:20)</a>:</h4>
<p>I'm not too familiar with dynamic linkers specifically, but my understanding is that they do not result in indirect function calls.  The calls are rewritten in some sense which is why you need PIC in dynamic libraries</p>



<a name="227022526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022526">(Feb 19 2021 at 20:20)</a>:</h4>
<p>no no, for the branching and mitigation stuff</p>



<a name="227022529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022529">(Feb 19 2021 at 20:20)</a>:</h4>
<p>Hardware nowadays either has zero branch prediction and audaciously claims it can do better by simply going faster, or has pretty good branch prediction on even fairly tiny and unimportant CPUs.</p>



<a name="227022626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022626">(Feb 19 2021 at 20:21)</a>:</h4>
<p>One general comment, BTW: all else being equal, if we need to prioritize compile-time optimization versus runtime detection, I would <em>generally</em> tend to prioritize compile-time detection first, as long as we leave the door open for runtime detection. I realize that they address different use cases, but all else being equal, compile-time optimization tends to maximize performance for people who know their target, and it's always possible to ship multiple copies of something that are compiled differently and make a top-level choice of which one to install/run/link.</p>
<p>A world in which compile-time optimization is done and we're working on runtime detection is one where people can get the fastest code and they might have to do a little more work to implement runtime detection themselves. (How much work you need to do depends on how much you want to deduplicate; if you don't care about binary size or duplicate binaries too much, it's <em>easy</em>.) A world in which runtime detection is done and compile-time optimization isn't available yet is one where people get less performance and larger binaries, and have no ability to avoid that for cases where they know their hardware target.</p>



<a name="227022642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022642">(Feb 19 2021 at 20:21)</a>:</h4>
<p>That's leaving aside that compile-time detection should be easier.</p>



<a name="227022806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022806">(Feb 19 2021 at 20:23)</a>:</h4>
<p>I think we're all on the same page with that for the most part, fortunately.  I think I may just be more biased towards runtime detection than some <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="227022836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022836">(Feb 19 2021 at 20:23)</a>:</h4>
<p>Our main problem with compile time detection is basically "so, std".</p>



<a name="227022842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022842">(Feb 19 2021 at 20:23)</a>:</h4>
<p>atm.</p>



<a name="227022877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022877">(Feb 19 2021 at 20:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227022806">said</a>:</p>
<blockquote>
<p>I think we're all on the same page with that for the most part, fortunately.  I think I may just be more biased towards runtime detection than some <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>
</blockquote>
<p>I <em>absolutely</em> want runtime detection too. I think I'm more or less saying "if you have compile-time then runtime can be put together by hand without too much trouble; the reverse is not true".</p>



<a name="227022954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227022954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227022954">(Feb 19 2021 at 20:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227022836">said</a>:</p>
<blockquote>
<p>Our main problem with compile time detection is basically "so, std".</p>
</blockquote>
<p>Right, hence my suggestion for the quick-and-dirty approach of "compile four copies of std". :)</p>



<a name="227023009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227023009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227023009">(Feb 19 2021 at 20:24)</a>:</h4>
<p>So in this particular scenario, optimizing compile time detection for round etc precludes runtime detection unless we fix LLVM, which is unusual I think</p>



<a name="227023016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227023016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227023016">(Feb 19 2021 at 20:24)</a>:</h4>
<p>We could do much much better than multiple copies of std, but that'd be an <em>easy</em> approach to experiment with, and in the short term we could shove the optimized versions into a separate rustup component.</p>



<a name="227023097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227023097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227023097">(Feb 19 2021 at 20:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227023009">said</a>:</p>
<blockquote>
<p>So in this particular scenarios, optimizing compile time detection for round etc precludes runtime detection unless we fix LLVM, which is unusual I think</p>
</blockquote>
<p>Can you summarize why, again? IIRC the problem was just that LLVM emits calls to libm, which is painful if you could have inlined something but on the other hand the libm call may go to an optimized version?</p>



<a name="227023556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227023556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227023556">(Feb 19 2021 at 20:29)</a>:</h4>
<p>So the fundamental reason is that all of the functions in stdsimd are #[inline] to ensure codegen happens at the appropriate target feature level.  It plays nice with both compile and runtime detection.</p>
<p>A few LLVM intrinsics generate exceptionally bad code via calls to libm at the base feature level, but because of the inlining they still lower to optimal instructions if you have the appropriate features (like SSE4.1 will generate <code>roundps</code> instead of repeated calls to libm)</p>
<p>If we instead write a generic vector implementation of round we could produce good results on base x86-64, but once you hit SSE4.1 or higher it will do significantly worse because we are not emitting the correct instruction to LLVM to generate the platform round instructions</p>



<a name="227023714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227023714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227023714">(Feb 19 2021 at 20:30)</a>:</h4>
<p>LLVM has very recently added support for calling vector math libraries instead of libm (like libmvec, Accelerate, or SVML) which would allow us to fix the problem at the root</p>



<a name="227023720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227023720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227023720">(Feb 19 2021 at 20:30)</a>:</h4>
<p>Basically, the libm version is not "SSE aware" and so does not make good use of the baseline capabilities it has and what it can do.</p>



<a name="227023761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227023761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227023761">(Feb 19 2021 at 20:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227023556">said</a>:</p>
<blockquote>
<p>So the fundamental reason is that all of the functions in stdsimd are #[inline] to ensure codegen happens at the appropriate target feature level.  It plays nice with both compile and runtime detection.</p>
<p>A few LLVM intrinsics generate exceptionally bad code via calls to libm at the base feature level, but because of the inlining they still lower to optimal instructions if you have the appropriate features (like SSE4.1 will generate <code>roundps</code> instead of repeated calls to libm)</p>
<p>If we instead write a generic vector implementation of round we could produce good results on base x86-64, but once you hit SSE4.1 or higher it will do significantly worse because we are not emitting the correct instruction to LLVM to generate the platform round instructions</p>
</blockquote>
<p>Would that still be an issue if we had multiple copies of <code>std</code>, such that base x86-64 uses one implementation, and x86-64 with SSE4.1 or higher uses a different implementation that <em>does</em> use the platform round instructions?</p>



<a name="227024073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227024073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227024073">(Feb 19 2021 at 20:33)</a>:</h4>
<p>I think it would probably not be a problem necessarily, but there are machines that support <code>vroundps</code> but don't have AVX2 and therefore aren't x86-64-v3. Maybe not a super significant problem with that solution but that is why fixing it in codegen would be "right".</p>



<a name="227024190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227024190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227024190">(Feb 19 2021 at 20:34)</a>:</h4>
<p>Not to mention LLVM already has the architecture in place for using math vector libraries</p>



<a name="227024271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227024271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227024271">(Feb 19 2021 at 20:35)</a>:</h4>
<p>If rust already supported multiple stds it would probably be a "good enough" solution</p>



<a name="227024335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227024335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227024335">(Feb 19 2021 at 20:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227024073">said</a>:</p>
<blockquote>
<p>I think it would probably not be a problem necessarily, but there are machines that support <code>vroundps</code> but don't have AVX2 and therefore aren't x86-64-v3. Maybe not a super significant problem with that solution but that is why fixing it in codegen would be "right".</p>
</blockquote>
<p>That's an argument that the microarchitecture feature levels (v2 vs v3) don't have enough granularity. It'd be helpful to know how many extant machines actually fall in that category, because I know the microarchitecture feature levels were fairly carefully designed.</p>



<a name="227024679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227024679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227024679">(Feb 19 2021 at 20:38)</a>:</h4>
<p>I think it's less important to worry about the fine granularity of "is this optimized as well as it could possibly be for 8-year-old processors", and more important to handle "does it run reasonably well on all processors going as far back as we want to support, and does it take advantage of major optimizations".</p>



<a name="227024719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227024719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227024719">(Feb 19 2021 at 20:38)</a>:</h4>
<p>If it's not <em>perfect</em> for systems with AVX-but-not-AVX2, that's not the end of the world; it's still better than it would have been.</p>



<a name="227024949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227024949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227024949">(Feb 19 2021 at 20:40)</a>:</h4>
<p>Sandy Bridge and Ivy Bridge had AVX but not AVX2. Ivy Bridge is a 2012 processor. (Haswell is 2013, and has AVX2.). So, a CPU that this case would be optimizing for would be 8+ years old.</p>



<a name="227024981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227024981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227024981">(Feb 19 2021 at 20:40)</a>:</h4>
<p>And we'd still be using a SSE4.1 implementation for that case, which is better than the SSE2 implementation we're using today.</p>



<a name="227025046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025046">(Feb 19 2021 at 20:41)</a>:</h4>
<p>I actually don't think it's an important argument about granularity, realistically the solution would be good enough for most processors. It was just an example of why fixing it in codegen is probably the most "correct" solution</p>



<a name="227025087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025087">(Feb 19 2021 at 20:41)</a>:</h4>
<p>No argument there. Though if you're doing multiversioning, that kind of granularity question determines how many different versions you need and thus how much extra code.</p>



<a name="227025179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025179">(Feb 19 2021 at 20:42)</a>:</h4>
<p>So even if you fix it in codegen, you might choose to just ship (for instance) x86-64-v3 and baseline.</p>



<a name="227025184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025184">(Feb 19 2021 at 20:42)</a>:</h4>
<p>Yeah agreed. I really like the idea of the architecture levels for multiversioning.</p>



<a name="227025255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025255">(Feb 19 2021 at 20:42)</a>:</h4>
<p>having multiple std libraries shipped effectively defeats this problem even with no llvm change</p>



<a name="227025296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025296">(Feb 19 2021 at 20:43)</a>:</h4>
<p>but it's maybe a bigger change overall than just a pr to llvm</p>



<a name="227025300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025300">(Feb 19 2021 at 20:43)</a>:</h4>
<p>But until we can actually ship multiple versions of std, fixing it by manually implementing these functions entirely precludes runtime detection</p>



<a name="227025344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025344">(Feb 19 2021 at 20:43)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> wouldn't the level 2 version just emit <code>roundps</code> anyways instead of <code>vroundps</code>?</p>



<a name="227025411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025411">(Feb 19 2021 at 20:44)</a>:</h4>
<p>yeah, but like, thus would all be during the nightl-only period, so it's not a big deal</p>



<a name="227025422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025422">(Feb 19 2021 at 20:44)</a>:</h4>
<p>I say, having noodled around with compiler feature levels for a bit before asking this question and so already knowing the answer :^)</p>



<a name="227025435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025435">(Feb 19 2021 at 20:44)</a>:</h4>
<p>Sure. I'm wondering how much work it would be to skip the "manually implementing" step and just shipping multiple versions of std.</p>



<a name="227025458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025458">(Feb 19 2021 at 20:44)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> Yes but I'm not aware of any processors that have SSE4.1 but not 4.2</p>



<a name="227025460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025460">(Feb 19 2021 at 20:44)</a>:</h4>
<p>Any hypotheses on the amount of work multiple versions of std would be?</p>



<a name="227025476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025476">(Feb 19 2021 at 20:44)</a>:</h4>
<p>I think that's a question for infra.</p>



<a name="227025496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025496">(Feb 19 2021 at 20:44)</a>:</h4>
<p>Yeah I think that's well outside of our scope lol</p>



<a name="227025516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025516">(Feb 19 2021 at 20:44)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> It's partly an infra question, but that's not the part I'm poking at.</p>



<a name="227025539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025539">(Feb 19 2021 at 20:45)</a>:</h4>
<p>"can we build and ship more stuff" is an infra question.</p>



<a name="227025548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025548">(Feb 19 2021 at 20:45)</a>:</h4>
<p>the non sse4 version of what llvm naturally does is so extremely bad <span class="user-mention" data-user-id="239881">@Josh Triplett</span> , we can't in good conscience ship that</p>



<a name="227025580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025580">(Feb 19 2021 at 20:45)</a>:</h4>
<p>The stdsimd end is the same exact amount of work as if we implement our own version of libmvec</p>



<a name="227025585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025585">(Feb 19 2021 at 20:45)</a>:</h4>
<p>"can the compiler make the appropriate decisions about which std to link to" is a compiler question.</p>



<a name="227025599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025599">(Feb 19 2021 at 20:45)</a>:</h4>
<p>It just changes where we implement it</p>



<a name="227025616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025616">(Feb 19 2021 at 20:45)</a>:</h4>
<p>hmm.</p>



<a name="227025716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025716">(Feb 19 2021 at 20:46)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> questions are never outside of our scope, just actions</p>



<a name="227025753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025753">(Feb 19 2021 at 20:46)</a>:</h4>
<p>Oh yeah, I meant implementation would be</p>



<a name="227025763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025763">(Feb 19 2021 at 20:46)</a>:</h4>
<p>If folks here think that making rustc capable of deciding which library to link at compile time is reasonably feasible, I can ask infra what it'd take to actually do that. (It'd also help to have a sketch of how much build time that'd add.)</p>



<a name="227025814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025814">(Feb 19 2021 at 20:47)</a>:</h4>
<p>What fraction of a full rust toolchain build is the building of <code>std</code>?</p>



<a name="227025875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025875">(Feb 19 2021 at 20:47)</a>:</h4>
<p>In my experience not that much, rustc seems much longer, but that's anecdotal</p>



<a name="227025975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025975">(Feb 19 2021 at 20:48)</a>:</h4>
<p>My concern is more that the implementation is non-trivial. Wouldn't the symbols need to be mangled differently since they both end up in the binary?</p>



<a name="227025992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227025992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227025992">(Feb 19 2021 at 20:48)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> Penryn, VIA Nano, basically, lol?<br>
Otherwise, most processors that support SSE4.1 also support SSE4.2, yes.<br>
That or they support just SSE4a (some of the earlier AMD processors!)</p>



<a name="227026009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026009">(Feb 19 2021 at 20:48)</a>:</h4>
<p>building core/std is so cheap you can do it with an experimental cargo feature. depends on the OS, but I'd guess "a few minutes at most"</p>



<a name="227026050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026050">(Feb 19 2021 at 20:49)</a>:</h4>
<p>building core for arm is like, seconds</p>



<a name="227026229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026229">(Feb 19 2021 at 20:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227025975">said</a>:</p>
<blockquote>
<p>My concern is more that the implementation is non-trivial. Wouldn't the symbols need to be mangled differently since they both end up in the binary?</p>
</blockquote>
<p>That depends. Ideally you'd only have one copy: the one for your target feature level. And every call into core/std would use that. But I can imagine scenarios where you might end up with more than one, in which case mangling might come into play.</p>



<a name="227026262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026262">(Feb 19 2021 at 20:50)</a>:</h4>
<p>rebuilding std is fast enough that I was fairly serious about my earlier proposal to just optimize for SSE2 and recommend people rebuild std.</p>



<a name="227026293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026293">(Feb 19 2021 at 20:50)</a>:</h4>
<p>I can imagine a simple implementation that just allows one copy of core/std based on target feature.</p>



<a name="227026319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026319">(Feb 19 2021 at 20:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227026262">said</a>:</p>
<blockquote>
<p>rebuilding std is fast enough that I was fairly serious about my earlier proposal to just optimize for SSE and recommend people rebuild std.</p>
</blockquote>
<p>I don't think you want the portable-simd project gated behind build-std becoming stable.</p>



<a name="227026328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026328">(Feb 19 2021 at 20:51)</a>:</h4>
<p>That'll be a while.</p>



<a name="227026343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026343">(Feb 19 2021 at 20:51)</a>:</h4>
<p>and everyone went "nooooo!" :^)</p>



<a name="227026352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026352">(Feb 19 2021 at 20:51)</a>:</h4>
<p>that's true.</p>



<a name="227026369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026369">(Feb 19 2021 at 20:51)</a>:</h4>
<p>no i also think that's the best plan, for real</p>



<a name="227026390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026390">(Feb 19 2021 at 20:51)</a>:</h4>
<p>because it's not gated behind, it all still works without build-std</p>



<a name="227026421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026421">(Feb 19 2021 at 20:51)</a>:</h4>
<p>it's just sub-optimal, which is ultimately fine</p>



<a name="227026422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026422">(Feb 19 2021 at 20:51)</a>:</h4>
<p>I think long term I would <em>love</em> to rely on build-std for this kind of thing.</p>



<a name="227026474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026474">(Feb 19 2021 at 20:52)</a>:</h4>
<p>zig does ;P</p>



<a name="227026531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026531">(Feb 19 2021 at 20:52)</a>:</h4>
<p>Short-term, it might be possible to simulate the use of build-std by shipping a few different stds.</p>



<a name="227026542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026542">(Feb 19 2021 at 20:52)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> do you mean compile time target feature? Because then that doesn't solve the libm problem</p>



<a name="227026556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026556">(Feb 19 2021 at 20:52)</a>:</h4>
<p>Which would change "suboptimal" to "fairly good".</p>



<a name="227026572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026572">(Feb 19 2021 at 20:52)</a>:</h4>
<p>(though it's still probably a desirable feature for other reasons)</p>



<a name="227026602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026602">(Feb 19 2021 at 20:53)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> it does, because then the standard library can use cfg and it works right</p>



<a name="227026651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026651">(Feb 19 2021 at 20:53)</a>:</h4>
<p>No it doesn't, because if you enable AVX with #[target_feature] you still won't get <code>vroundps</code> if your base feature set is v1</p>



<a name="227026783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026783">(Feb 19 2021 at 20:54)</a>:</h4>
<p>oh right, because of that other garbage</p>



<a name="227026828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026828">(Feb 19 2021 at 20:55)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> I'm talking about building the whole std with <code>-C target-feature=...</code>. Does <em>that</em> not emit <code>vroundps</code> if AVX2 is enabled? If not, we need to fix that, yeah.</p>



<a name="227026854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026854">(Feb 19 2021 at 20:55)</a>:</h4>
<p>That absolutely does.</p>



<a name="227026873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026873">(Feb 19 2021 at 20:55)</a>:</h4>
<p>That's what I'm proposing when I say "multiple versions of std".</p>



<a name="227026886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026886">(Feb 19 2021 at 20:55)</a>:</h4>
<p>Build it once for baseline, once for target-feature=x86-64-v2, etc.</p>



<a name="227026899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026899">(Feb 19 2021 at 20:55)</a>:</h4>
<p>it does, but caleb wants to make a binary that is portable with and without avx support</p>



<a name="227026977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227026977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227026977">(Feb 19 2021 at 20:56)</a>:</h4>
<p>I understand that.</p>



<a name="227027023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027023">(Feb 19 2021 at 20:56)</a>:</h4>
<p>And there are still a few ways to do that once you have functioning compile-time support.</p>



<a name="227027051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027051">(Feb 19 2021 at 20:56)</a>:</h4>
<p>and basically as it is now, you have to use target_feature(enable) but that <em>doesn't</em> change the cfg settings within a function</p>



<a name="227027112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027112">(Feb 19 2021 at 20:57)</a>:</h4>
<p>In fact it can't, since cfg must be consistent across a crate</p>



<a name="227027127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027127">(Feb 19 2021 at 20:57)</a>:</h4>
<p>so if avx isn't on in a build cfg(avx) will be false, and target_feature_enavle(avx) doesn't make it true, it's still false</p>



<a name="227027182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027182">(Feb 19 2021 at 20:57)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> in this case, I'm pressing X to doubt pretty hard</p>



<a name="227027259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027259">(Feb 19 2021 at 20:58)</a>:</h4>
<p>we <em>could</em> fix it for this probably, or introduce an alternative mechanism</p>



<a name="227027513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027513">(Feb 19 2021 at 21:00)</a>:</h4>
<p>Actually, I think it's almost nearly impossible to fix it that way, since you can't reason about what the feature set of a function you inline into will be</p>



<a name="227027536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027536">(Feb 19 2021 at 21:00)</a>:</h4>
<p>As far as I can tell <em>only</em> codegen is privy to that</p>



<a name="227027539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027539">(Feb 19 2021 at 21:00)</a>:</h4>
<p>If we want to fix the inline case, we <em>have</em> to fix it in codegen.</p>



<a name="227027567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027567">(Feb 19 2021 at 21:01)</a>:</h4>
<p>But if we want to handle simple runtime detection that's as capable as function multiversioning, we don't have to cover that.</p>



<a name="227027630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027630">(Feb 19 2021 at 21:01)</a>:</h4>
<p>You could have the equivalent of a <code>func_x86_64_v3</code> and a <code>func_x86_64</code> and call the right one at runtime, without fixing codegen. You just can't inline one or the other based on target features without fixing codegen.</p>



<a name="227027710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027710">(Feb 19 2021 at 21:02)</a>:</h4>
<p>I think it makes more sense to fix codegen than to make something like cfg(target_feature) that only works sometimes</p>



<a name="227027762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027762">(Feb 19 2021 at 21:02)</a>:</h4>
<p>/me is confused.</p>



<a name="227027775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027775">(Feb 19 2021 at 21:02)</a>:</h4>
<p>What would the latter be referring to?</p>



<a name="227027825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027825">(Feb 19 2021 at 21:03)</a>:</h4>
<p>I am also slightly confused.</p>



<a name="227027848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027848">(Feb 19 2021 at 21:03)</a>:</h4>
<p>Also I want to reiterate one thing that I think everyone knows but is important and underlines Lokathor's point:</p>
<p>On processors with SIMD registers, especially <strong>older</strong> processors, moving between SIMD and scalar can be slow. So that's part of why we want to avoid calls to libm even on the baseline SSE2 feature level, because we have good reason to <strong>really doubt</strong> that libm will actually do better.</p>



<a name="227027851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027851">(Feb 19 2021 at 21:03)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> is suggesting you could make cfg work with the target feature attribute</p>



<a name="227027895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027895">(Feb 19 2021 at 21:03)</a>:</h4>
<p>But like you said it wouldn't work with inlining anyway</p>



<a name="227027904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027904">(Feb 19 2021 at 21:03)</a>:</h4>
<p>I don't think we should go that route rather than fixing codegen.</p>



<a name="227027934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227027934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227027934">(Feb 19 2021 at 21:03)</a>:</h4>
<p>If we're going to try to fix the compiler to understand target features in this way, let's just fix codegen and be done with it.</p>



<a name="227028023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028023">(Feb 19 2021 at 21:04)</a>:</h4>
<p>Yeah agreed. I'd like the compiler to do that eventually but I think that's a very long way out.</p>



<a name="227028049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028049">(Feb 19 2021 at 21:04)</a>:</h4>
<p>The goal of compiling multiple versions of std (and letting people do the same with other libraries) would be to sidestep that, and also to avoid needing build-std to get optimized versions of std.</p>



<a name="227028064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028064">(Feb 19 2021 at 21:04)</a>:</h4>
<p><em>nods</em></p>



<a name="227028106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028106">(Feb 19 2021 at 21:04)</a>:</h4>
<p>It'd also be really helpful for distributions like Debian, which build std as a shared library; they could build multiple copies and ship them in the directories specific to architecture feature level libraries.</p>



<a name="227028172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028172">(Feb 19 2021 at 21:05)</a>:</h4>
<p>I guess I'm confused how building multiple versions of std fixes this particular problem since all of our functions are inline and therefore don't get distributed as compiled asm anyway</p>



<a name="227028185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028185">(Feb 19 2021 at 21:05)</a>:</h4>
<p>"here's the std .so for baseline x86-64, here's the one for x86-64-v3, the dynamic linker will DTRT".</p>



<a name="227028193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028193">(Feb 19 2021 at 21:05)</a>:</h4>
<p>I think it's worthwhile for other reasons but I still don't think it fixes this at all</p>



<a name="227028261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028261">(Feb 19 2021 at 21:06)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> Multiple versions of std also means multiple rlibs and thus multiple versions of inline-able code too.</p>



<a name="227028326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028326">(Feb 19 2021 at 21:06)</a>:</h4>
<p>You'd inline the version that corresponds to how you're compiling your crate.</p>



<a name="227028357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028357">(Feb 19 2021 at 21:06)</a>:</h4>
<p>If you build your crate with <code>-C target-feature=x86-64-v3</code>, rustc would link you to the x86-64-v3 std, and also use that std for inlining.</p>



<a name="227028361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028361">(Feb 19 2021 at 21:06)</a>:</h4>
<p>Am I confused or would this still not work in the runtime detection case?</p>



<a name="227028552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028552">(Feb 19 2021 at 21:08)</a>:</h4>
<p>When I said there are ways to build that runtime detection yourself, I was suggesting that you could (for instance) build multiple copies of your crate and pick which one to install on the target system, or you could build the part of your crate that cares about such optimizations as a shared library and install multiple shared libraries, or you could compile several static objects with different symbols and different optimization levels and hand-roll multiversioning...</p>



<a name="227028639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028639">(Feb 19 2021 at 21:08)</a>:</h4>
<p>You wouldn't just be able to do <code>cfg</code> within your own crate and write several side-by-side functions with different feature levels, unless we fix enough of codegen to make that work.</p>



<a name="227028642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028642">(Feb 19 2021 at 21:08)</a>:</h4>
<p>Okay, so it <em>would not</em> be compatible with #[target_feature]</p>



<a name="227028664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028664">(Feb 19 2021 at 21:08)</a>:</h4>
<p>But you <em>could</em> still get runtime detection to work, by several other routes.</p>



<a name="227028695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028695">(Feb 19 2021 at 21:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227028642">said</a>:</p>
<blockquote>
<p>Okay, so it <em>would not</em> be compatible with #[target_feature]</p>
</blockquote>
<p>Right. It'd <em>only</em> be compatible with <code>-C target-feature</code>, unless we fixed that.</p>



<a name="227028730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028730">(Feb 19 2021 at 21:09)</a>:</h4>
<p>I personally think that's an acceptable trade-off for a very simple solution, while we're working on fixing codegen.</p>



<a name="227028757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028757">(Feb 19 2021 at 21:09)</a>:</h4>
<p>I think that's probably not a good solution because in general people should expect #[target_feature] to work</p>



<a name="227028776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028776">(Feb 19 2021 at 21:09)</a>:</h4>
<p>And it's also something we'll need even <em>after</em> we fix codegen, for other reasons.</p>



<a name="227028843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028843">(Feb 19 2021 at 21:10)</a>:</h4>
<p>Do we really think that's easier than fixing it in codegen? LLVM already has support for calling vector libraries</p>



<a name="227028905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028905">(Feb 19 2021 at 21:10)</a>:</h4>
<p>We don't want to call vector libraries, we want to generate inline code.</p>



<a name="227028918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028918">(Feb 19 2021 at 21:10)</a>:</h4>
<p>This has already gone in a circle.</p>



<a name="227028955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028955">(Feb 19 2021 at 21:10)</a>:</h4>
<p>Yeah, I don't think we need to rehash this further.</p>



<a name="227028989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227028989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227028989">(Feb 19 2021 at 21:10)</a>:</h4>
<p>If you static link the vector library it can't inline that code?</p>



<a name="227029009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029009">(Feb 19 2021 at 21:11)</a>:</h4>
<p>I think there are a few possibilities available at this point, and it'd be reasonable to decide which one to go forward with first, as well as what the long-term plan is.</p>



<a name="227029126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029126">(Feb 19 2021 at 21:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227028989">said</a>:</p>
<blockquote>
<p>If you static link the vector library it can't inline that code?</p>
</blockquote>
<p>Only if the vector library were to ship LTO-capable bitcode using a compatible toolchain to allow cross-language inlining.</p>



<a name="227029137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029137">(Feb 19 2021 at 21:12)</a>:</h4>
<p>Otherwise, no.</p>



<a name="227029199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029199">(Feb 19 2021 at 21:12)</a>:</h4>
<p>I am suggesting we write the vector library ourselves in Rust</p>



<a name="227029225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029225">(Feb 19 2021 at 21:12)</a>:</h4>
<p>And compile it as part of stdsimd</p>



<a name="227029268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029268">(Feb 19 2021 at 21:12)</a>:</h4>
<p>I see. So you're talking about using LLVM's support for calling a vector math library, but shipping our own such library. Do we know that'll work with LLVM and produce appropriate inlined code that's just as efficient as using <code>-C target-feature=...</code> in the first place?</p>



<a name="227029390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029390">(Feb 19 2021 at 21:13)</a>:</h4>
<p>I do not know that it will inline efficiently, but I do know that it will still work with #[target_feature]</p>



<a name="227029470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029470">(Feb 19 2021 at 21:14)</a>:</h4>
<p>I'm more concerned about the former than the latter. I acknowledge that you may prioritize those differently.</p>



<a name="227029497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029497">(Feb 19 2021 at 21:14)</a>:</h4>
<p>(I tried an example further up in this thread with llc)</p>



<a name="227029614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029614">(Feb 19 2021 at 21:15)</a>:</h4>
<p>I think that's an especially important consideration for a potential long-term solution: if the optimized version using LLVM's vector math support and a Rust math library isn't as efficient as more direct codegen/inlining would be, then it isn't the right long term solution.</p>



<a name="227029645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029645">(Feb 19 2021 at 21:15)</a>:</h4>
<p>Right, well I would like to see if it inlines. To be honest I don't know how to mark a function as inlinable in LLVM IR (or would it have to be LTO at that point?)</p>



<a name="227029704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029704">(Feb 19 2021 at 21:16)</a>:</h4>
<p>Also I'm not convinced that these functions should be inlined?  They're very large</p>



<a name="227029778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029778">(Feb 19 2021 at 21:16)</a>:</h4>
<p>Some of the trig functions are extremely large</p>



<a name="227029817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029817">(Feb 19 2021 at 21:16)</a>:</h4>
<p>To answer a much earlier question:</p>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227022523">said</a>:</p>
<blockquote>
<p>I'm not too familiar with dynamic linkers specifically, but my understanding is that they do not result in indirect function calls.  The calls are rewritten in some sense which is why you need PIC in dynamic libraries</p>
</blockquote>
<p>They don't end up doing indirect function calls in the common case. There are a couple of different approaches commonly used. Here's my understanding, off the top of my head:</p>
<p>A long time ago, the standard approach was static relocations, where if you used <code>call xyz</code> in your code, the compiler would emit a call to a fixed address but add a relocation table entry noting the location of that fixed address in your code, and when dynamic linking it would patch in the address it put <code>xyz</code> at. That doesn't have an indirect call, but it means patching code at runtime, which also makes it harder to mark all the code segments read-only, and thus isn't quite as secure. It also means that on your system, in memory, every copy of a shared library in a different process may get a different address patched into its code, which means the code pages have different contents, so they can't actually be shared in virtual memory; so, if you had 30 programs using libc, you'd have 30 copies of libc in memory with different addresses patched in.</p>
<p>To avoid those problems, current dynamic linkers (for many many years) make calls through the "program load table" (PLT), where calls look like <code>call xyz@PLT</code> in assembly. That's still a direct call (albeit typically a position-independent one). The first time it's called (or when the program is first run if doing <code>bindnow</code>/<code>LD_BIND_NOW</code>), the code in the PLT loads an index into a register and calls common code, which figures out the correct address for the symbol, patches the PLT entry into a direct call for the next call, and then makes that call. Subsequent times it's just a call-then-jmp. This allows position-independent code (as long as the PLT is at a known offset relative to the call instruction).</p>
<p>Position-independent code used to be more expensive on baseline x86, because you needed to get the current instruction pointer to offset from, which caused more register pressure (you had to have a register to put the IP into and then offset from) but on x86-64 it's cheap and almost always used, because there's a <code>%rip</code> register you can reference for that. So, <em>most</em> code on x86-64 these days is built position-independent, including both binaries and shared libraries, both for deduplication in virtual memory and because position-independent code also allows for security improvements like ASLR.</p>
<p>Multiversioning extends that use of the PLT to also check the equivalent of CPUID (it uses <code>AT_HWCAP</code>/<code>AT_HWCAP2</code> from the auxiliary vector, provided by the kernel), and make the PLT reference the appropriate symbol based on CPU features.</p>
<p>The GOT is similar to the PLT, but for data symbols rather than function symbols, and it's always resolved at initial load time and doesn't need anything like multiversioning.</p>



<a name="227029991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227029991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227029991">(Feb 19 2021 at 21:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20libm.20problem/near/227029704">said</a>:</p>
<blockquote>
<p>Also I'm not convinced that these functions should be inlined?  They're very large</p>
</blockquote>
<p>I would expect things as simple as <code>vroundps</code> to be an inline instruction, and a call would add overhead to that.</p>



<a name="227030101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030101">(Feb 19 2021 at 21:18)</a>:</h4>
<p>Oh let me clarify, when LLVM calls the vector math lib, it's only if it can't call vroundps etc</p>



<a name="227030140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030140">(Feb 19 2021 at 21:19)</a>:</h4>
<p>Ah, I see.</p>



<a name="227030143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030143">(Feb 19 2021 at 21:19)</a>:</h4>
<p>yeah, we'd be patching up the sub-sse4 case</p>



<a name="227030153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030153">(Feb 19 2021 at 21:19)</a>:</h4>
<p>If it generates to a codelet those are absolutely inlined.  The math lib fallbacks are not</p>



<a name="227030192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030192">(Feb 19 2021 at 21:19)</a>:</h4>
<p>"codelet"? (I can guess from context but would like clarification.)</p>



<a name="227030303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030303">(Feb 19 2021 at 21:20)</a>:</h4>
<p>I don't know if there's a better word. A specific string of instructions that implement an LLVM instruction</p>



<a name="227030447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030447">(Feb 19 2021 at 21:21)</a>:</h4>
<p>If it generates "a string of instructions that don't call the vector math lib" it doesn't result in a function call. If it calls the vector math lib as a fallback it does produce a single call (which is an improvement over the 4-8 calls to libm right now)</p>



<a name="227030781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030781">(Feb 19 2021 at 21:24)</a>:</h4>
<p>In a more specific example, if you are using SVML, it will generate <code>roundps</code> if you have sse4.1 but <code>call roundf32</code> (or whatever the function is called) if you don't</p>



<a name="227030957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030957">(Feb 19 2021 at 21:26)</a>:</h4>
<p>Actually that's not true, LLVM doesn't support it for <code>round</code> yet, which is where we would need to patch llvm.  This is true for other functions though</p>



<a name="227030990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227030990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227030990">(Feb 19 2021 at 21:26)</a>:</h4>
<p>LLVM supports sin, cos, exp, log</p>



<a name="227031285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227031285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227031285">(Feb 19 2021 at 21:29)</a>:</h4>
<p>Perhaps that's an argument for using multiple std as a stopgap for round specifically</p>



<a name="227031317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227031317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227031317">(Feb 19 2021 at 21:29)</a>:</h4>
<p>But that's a lot of work for one function</p>



<a name="227031492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227031492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227031492">(Feb 19 2021 at 21:30)</a>:</h4>
<p>My expectation is that having multiple versions of std would be about much more than just math functions.</p>



<a name="227031522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227031522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227031522">(Feb 19 2021 at 21:31)</a>:</h4>
<p>Inlined versions of memcpy/memmove, for instance.</p>



<a name="227031564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227031564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227031564">(Feb 19 2021 at 21:31)</a>:</h4>
<p>(Though the nice thing is that these days <code>rep movsb</code> is mostly the right answer.)</p>



<a name="227031689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227031689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227031689">(Feb 19 2021 at 21:32)</a>:</h4>
<p>Definitely agreed there</p>



<a name="227031697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227031697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227031697">(Feb 19 2021 at 21:32)</a>:</h4>
<p>I'm hoping that letting the compiler casually use non-baseline instructions whenever it sees an opportunity will optimize substantial portions of the standard library.</p>



<a name="227032454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20libm%20problem/near/227032454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20libm.20problem.html#227032454">(Feb 19 2021 at 21:39)</a>:</h4>
<p>BTW, I'm currently asking infra how feasible it'd be to ship multiple copies of std.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>